mappingRemove()

Deletes the entry (of a mapping) with a specified "key".

Synopsis

int mappingRemove(mapping &m, <type> key);

Parameters

Parameters Meaning
m Mapping
key The key of the entry that should be deleted.

Return value

The function returns 0 when the entries have been deleted successfully otherwise, -1.

Error

0 when the function was executed successfully, otherwise -1.

Description

Deletes the entry (of a mapping) with the specified "key".Mappings save arbitrary key and value pairs. The keys and values are saved in two arrays (one for keys and one for values). A mapping with key:value pairs "one": 1, "two":2, "three":3 looks internally as follows:

key value

"one" 1

"two" 2

"three" 3

The values for the keys are searched via the keys. The keys can be of an arbitrary type and the types can be mixed (so that not only one type is used). If you want to find the value for the key "one", the position of the key "one" will be searched in the key array and the value at this position in the value array will be returned.

Example

main()
{
  int i;
  mapping m;
  m["one"]=1;//sets the value to 1
  m["two"]=2;//sets the value to 2
  DebugN("The value of m[one]is="+m["one"], "the value should
  be=1");
  DebugN("The value of m[two]is="+m["two"], "the value should
  be=2");
  i = m["one"];//sets i to the value of "one"
  DebugN("i is="+i, "i should be =1");
  DebugN("mappingRemove: one", "is="+mappingRemove(m, "one"),
  "should be=0");
}

Assignment

Miscellaneous functions (mapping)

Availability

CTRL, UI