Share via


Map.elements Method

Returns the number of elements in the map.

Syntax

public int elements()

Run On

Called

Return Value

Type: int
The number of elements in the map.

Remarks

The number of elements in the map is equal to the number of different key values in the map.

Examples

The following example uses the elements method to check whether a map has any elements. If the _from map exists, and has some elements, the values from the _from map are inserted into the _to map.

static void mergeRecsPrim( 
    Map _from, 
    Map _to 
    ) 
{ 
    MapEnumerator   me; 
  
    if (! _from) 
    { 
        return; 
    } 
 
    if (! _from.elements()) 
    { 
        return; 
    } 
 
    me = _from.getEnumerator(); 
    while (me.moveNext()) 
    { 
        _to.insert(me.currentKey(),me.currentValue()); 
    } 
} 

See Also

Map Class

MapEnumerator Class

Map.empty Method