Interface org.as2lib.data.holder.Map

org.as2lib.core.BasicInterface
   +--org.as2lib.data.holder.Map

Description

Map is the base interface for data holders that map keys to values.

A map offers two methods that help you find out whether it contains a specific key or value. These two methods are containsKey and containsValue.

To get the data stored in the map you can use the methods getKeys, getValues and get. If you want to iterate over the values of the map you can use the iterators returned by the methods iterator or valueIterator. If you want to iterate over the keys you can use the iterator returned by the keyIterator method.

To add key value pairs to the map you can use the methods put and putAll. The putAll method lets you add all key-value pairs contained in the passed-in map to this map.

To remove key-value pairs you can use the methods remove and clear. The remove method deletes only the key-value pair corresponding to the passed-in key, while the clear method removes all key-value pairs.

There are two more methods you may need. The isEmpty and the size method. These methods give you information about whether this map contains any mappings and how many mappings it contains.

Example: // the map gets set up somewhere var map:Map = new MyMap(); map.put("myKey", "myValue"); // at some different place in your code if (map.containsKey("myKey")) { trace(map.get("myKey")); }

Method Index

clear(), containsKey(), containsValue(), get(), getKeys(), getValues(), isEmpty(), iterator(), keyIterator(), put(), putAll(), remove(), size(), valueIterator()

Inherited from BasicInterface

toString()

Method Detail

containsKey

public function containsKey(key):Boolean

Checks if the passed-in key exists.

That means whether a value has been mapped to it.

Parameters

keythe key to be checked for availability

Return

true if the key exists else false

containsValue

public function containsValue(value):Boolean

Checks if the passed-in value is mapped to a key.

Parameters

valuethe value to be checked for availability

Return

true if the value is mapped to a key else false

getKeys

public function getKeys(Void):Array

Returns an array that contains all keys that have a value mapped to it.

Return

an array that contains all keys

getValues

public function getValues(Void):Array

Returns an array that contains all values that are mapped to a key.

Return

an array that contains all mapped values

get

public function get(key)

Returns the value that is mapped to the passed-in key.

Parameters

keythe key to return the corresponding value for

Return

the value corresponding to the passed-in key

put

public function put(key, value)

Maps the given key to the value.

Parameters

keythe key used as identifier for the value
valuethe value to map to the key

Return

the value that was originally mapped to the key

putAll

public function putAll(map:Map):Void

Copies all mappings from the passed-in map to this map.

Parameters

mapthe mappings to add to this map

remove

public function remove(key)

Removes the mapping from the given key to the value.

Parameters

keythe key identifying the mapping to remove

Return

the value that was originally mapped to the key

clear

public function clear(Void):Void

Clears all mappings.

iterator

public function iterator(Void):Iterator

Returns an iterator to iterate over the values of this map.

Return

an iterator to iterate over the values of this map

valueIterator

public function valueIterator(Void):Iterator

Returns an iterator to iterate over the values of this map.

Return

an iterator to iterate over the values of this map

keyIterator

public function keyIterator(Void):Iterator

Returns an iterator to iterate over the keys of this map.

Return

an iterator to iterate over the keys of this map

size

public function size(Void):Number

Returns the amount of mappings.

Return

the amount of mappings

isEmpty

public function isEmpty(Void):Boolean

Returns whether this map contains any mappings.

Return

true if this map contains any mappings else false