Partilhar via


Map.elements Method

Definition

Returns the number of elements in the map.

public:
 int elements();
public int elements ();
member this.elements : unit -> int
Public Function elements () As Integer

Returns

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.

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()); 
    } 
}

Applies to