Map.insert(Object, Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Inserts an element (keyValue, valueValue pair) into the map.
public:
bool insert(System::Object ^ _keyValue, System::Object ^ _valueValue);
public bool insert (object _keyValue, object _valueValue);
member this.insert : obj * obj -> bool
Public Function insert (_keyValue As Object, _valueValue As Object) As Boolean
Parameters
- _keyValue
- Object
The value that is mapped to by the key.
- _valueValue
- Object
The value that is mapped to by the key.
Returns
true if the key did not already exist in the map and has been inserted; otherwise, false.
Remarks
If the key already exists in the map, the value is updated.
The following example checks whether the _from map has any elements and creates an enumerator for the map if it has any elements. The map is traversed, and the insert method is used to insert the elements from the _from map 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());
}
}