Access keys

KeyMapIterator

Kind of class: class
Inherits from: BasicClass
Implements:
Author: Simon Wacker
Classpath: org.as2lib.data.holder.map.KeyMapIterator
File last modified: Wednesday, 06 April 2005, 13:18:24
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 org.as2lib.data.holder.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();
// ...

Summary

Constructor
Instance methods
Instance methods inherited from BasicClass

Constructor

KeyMapIterator

function KeyMapIterator (
target:Map)
Constructs a new KeyMapIterator instance.
Parameters:
target:
the map to iterate over
Throws:
org.as2lib.env.except.IllegalArgumentException if the passed-in target map is null
or undefined

Instance methods

hasNext

function hasNext (
Void) : Boolean
Returns whether there exists another key to iterate over.
Returns:
true if there is at least one key left to iterate over

next

function next (
Void)
Returns the next key.
Returns:
the next key
Throws:

remove

function remove (
Void) : Void
Removes the currently selected key-value pair from this iterator and from the
map this iterator iterates over.
Throws:
org.as2lib.env.except.IllegalStateException if you try to remove a
key-value pair when none is selected