tmap.md 3.4 KB


id: tmap title: TMap

sidebar_label: TMap

An key/value (Object/Object) map backed by a Red/Black tree.

Operators

Method Operator[]:Object(key:Object)

Finds a value given a key using index syntax.

If the map does not contain key, a Null object is returned.

Returns

The value associated with key.

Example

SuperStrict

Framework brl.standardio
Import brl.map

Local map:TMap = New TMap

map.Insert("one", "Hello")
map.Insert("two", "World")

For Local s:String = EachIn map.Keys()
	Print s + " = " + String(map[s]) ' retrieve value using index operator
Next


Method Operator[]=(key:Object, value:Object)

Inserts a key/value pair into the map using index syntax.

If the map already contains key, its value is overwritten with value.

Example

SuperStrict

Framework brl.standardio
Import brl.map

Local map:TMap = New TMap

map["one"] = "Hello" ' insert value using index operator
map["two"] = "World"

For Local s:String = EachIn map.Keys()
	Print s + " = " + String(map.ValueForKey(s))
Next


Methods

Method Clear()

Clears the map.

Removes all keys and values.


Method IsEmpty:Int()

Checks if the map is empty.

True if map is empty, otherwise False.


Method Insert( key:Object,value:Object )

Inserts a key/value pair into the map.

If the map already contains key, its value is overwritten with value.


Method Contains:Int( key:Object )

Checks if the map contains key.

Returns

True if the map contains key.


Method ValueForKey:Object( key:Object )

Finds a value given a key.

If the map does not contain key, a Null object is returned.

Returns

The value associated with key.


Method ValueForKey:Int( key:Object, value:Object var )

Finds a value given a key, returning it via an output parameter.

Returns

True if key was found, otherwise False.


Method Remove:Int( key:Object )

Remove a key/value pair from the map.

Returns

True if key was removed, or False otherwise.


Method Keys:TMapEnumerator()

Gets the map keys.

The object returned by Keys can be used with EachIn to iterate through the keys in the map.

Returns

An enumeration object


Method Values:TMapEnumerator()

Get the map values.

The object returned by Values can be used with EachIn to iterate through the values in the map.

Returns

An enumeration object.


Method Copy:TMap()

Returns a copy the contents of this map.


Method ObjectEnumerator:TNodeEnumerator()

Returns a node enumeration Object.

The object returned by ObjectEnumerator can be used with EachIn to iterate through the nodes in the map.