Iterator
ValueMapIterator is used to iterate over the values 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 ValueMapIterator(map);
while (iterator.hasNext()) {
trace(iterator.next());
}
You normally do not use this class directly, but obtain an iterator that iterates over the values of a map using the Map.valueIterator 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.valueIterator();
// ...
public function ValueMapIterator(target:Map)
Constructs a new ValueMapIterator instance.
target | the map to iterate over |
| IllegalArgumentException | if the passed-in target map is null
or undefined
|
public function hasNext(Void):BooleanReturns whether there exists another value to iterate over.
true if there is at least one value left to iterate over
public function next(Void)Returns the next value.
the next value
| NoSuchElementException | if there is no next value |
public function remove(Void):VoidRemoves the currently selected key-value pair from this iterator and from the map this iterator iterates over.
| IllegalStateException | if you try to remove a key-value pair when none is selected |