Class org.as2lib.data.holder.map.KeyMapIterator

org.as2lib.core.BasicClass
   +--org.as2lib.data.holder.map.KeyMapIterator

Implemented Interfaces

Iterator

Description

KeyMapIterator is used to iterate over the keys of a map.

This iterator is quite simple to use. There is one method to check whether there are more elements left to iterate over hasNext, one method to get the next element next and one to remove the current element remove.

Example: var map:Map = new HashMap(); map.put("key1", 1); map.put("key2", 2); map.put("key3", 3); var iterator:Iterator = new KeyMapIterator(map); while (iterator.hasNext()) { trace(iterator.next()); }

You normally do not use this class directly, but obtain an iterator that iterates over the keys of a map using the Map.keyIterator method. The returned iterator can, but does not have to be an instance of this class.

Example: var map:Map = new HashMap(); // ... var iterator:Iterator = map.keyIterator(); // ...

Method Index

new KeyMapIterator()

hasNext(), next(), remove()

Inherited from BasicClass

toString()

Constructor Detail

KeyMapIterator

public function KeyMapIterator(target:Map)

Constructs a new KeyMapIterator instance.

Parameters

targetthe map to iterate over

Throws

IllegalArgumentExceptionif the passed-in target map is null or undefined

Method Detail

hasNext

public function hasNext(Void):Boolean

Returns whether there exists another key to iterate over.

Return

true if there is at least one key left to iterate over

Specified By

hasNext() in org.as2lib.data.holder.Iterator

next

public function next(Void)

Returns the next key.

Return

the next key

Throws

NoSuchElementExceptionif there is no next key

Specified By

next() in org.as2lib.data.holder.Iterator

remove

public function remove(Void):Void

Removes the currently selected key-value pair from this iterator and from the map this iterator iterates over.

Throws

IllegalStateExceptionif you try to remove a key-value pair when none is selected

Specified By

remove() in org.as2lib.data.holder.Iterator