LNXSDK/Kha/Tools/macos/std/haxe/iterators/HashMapKeyValueIterator.hx

29 lines
523 B
Haxe
Raw Normal View History

2025-01-22 16:18:30 +01:00
package haxe.iterators;
import haxe.ds.HashMap;
class HashMapKeyValueIterator<K:{function hashCode():Int;}, V> {
final map:HashMap<K, V>;
final keys:Iterator<K>;
public inline function new(map:HashMap<K, V>) {
this.map = map;
this.keys = map.keys();
}
/**
See `Iterator.hasNext`
**/
public inline function hasNext():Bool {
return keys.hasNext();
}
/**
See `Iterator.next`
**/
public inline function next():{key:K, value:V} {
var key = keys.next();
return {value: map.get(key), key: key};
}
}