HashMapIterator<K, V>
Forward iterator for HashMap, yields key-value pairs.
xxml
Language::CollectionsMethods
| Method | Parameters | Returns | Description |
|---|---|---|---|
| hasNext | — | Bool^ | More entries available |
| next | — | KeyValuePair<K,V>^ | Advance and return entry |
| current | — | KeyValuePair<K,V>^ | Current entry |
| currentKey | — | K& | Reference to current key |
| currentValue | — | V& | Reference to current value |
| reset | — | None | Return 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()));
}