HashMapIterator<K, V>

Forward iterator for HashMap, yields key-value pairs.

xxml
Language::Collections

Methods

MethodParametersReturnsDescription
hasNextBool^More entries available
nextKeyValuePair<K,V>^Advance and return entry
currentKeyValuePair<K,V>^Current entry
currentKeyK&Reference to current key
currentValueV&Reference to current value
resetNoneReturn to beginning

Examples

HashMap Iteration

xxml
Instantiate Collections::HashMap<String, Integer>^ As <scores> =
    Collections::HashMap@String, Integer::Constructor();
Run scores.put(String::Constructor("Alice"), Integer::Constructor(95));
Run scores.put(String::Constructor("Bob"), Integer::Constructor(87));

Instantiate Collections::HashMapIterator<String, Integer>^ As <iter> = scores.begin();
While (iter.hasNext()) -> {
    Instantiate Collections::KeyValuePair<String, Integer>^ As <entry> = iter.next();
    Run Console::printLine(entry.key().append(String::Constructor(": ")).append(entry.value().toString()));
}

See Also