<commit_before>package openfl.utils; #if (!flash || display)


import haxe.ds.StringMap;
import haxe.ds.IntMap;
import haxe.ds.HashMap;
import haxe.ds.ObjectMap;
import haxe.ds.WeakMap;
import haxe.ds.EnumValueMap;
import haxe.Constraints.IMap;

@:multiType(K)


abstract Dictionary<K, V> (IMap<K, V>) {
	
	
	public function new (weakKeys:Bool = false);
	
	
	public inline function exists (key:K):Bool {
		
		return this.exists (key);
		
	}
	
	
	@:arrayAccess public inline function get (key:K):V {
		
		return this.get (key);
		
	}
	
	
	public inline function remove (key:K):Bool {
		
		return this.remove (key);
		
	}
	
	
	@:arrayAccess public inline function set (key:K, value:V):V {
		
		this.set (key, value);
		return value;
		
	}
	
	
	public inline function iterator ():Iterator<K> {
		
		return this.keys ();
		
	}
	
	public inline function values ():Iterator<V> {
		
		return this.iterator ();
		
	}
	
	@:to static inline function toStringMap<K:String, V> (t:IMap<K, V>, weakKeys:Bool):StringMap<V> {
		
		return new StringMap<V> ();
		
	}
	
	
	@:to static inline function toIntMap<K:Int, V> (t:IMap<K, V>, weakKeys:Bool):IntMap<V> {
		
		return new IntMap<V> ();
		
	}
	
	
	@:to static inline function toEnumValueMapMap<K:EnumValue, V> (t:IMap<K, V>, weakKeys:Bool):EnumValueMap<K, V> {
		
		return new EnumValueMap<K, V> ();
		
	}
	
	
	@:to static inline function toObjectMap<K:{},V> (t:IMap<K, V>, weakKeys:Bool):ObjectMap<K, V> {
		
		return new ObjectMap<K, V> ();
		
	}
	
	
	@:to static inline function toUtilsObjectMap<K:Object,V> (t:IMap<K, V>, weakKeys:Bool):UtilsObjectMap<K, V> {
		
		return new UtilsObjectMap<K, V> ();
		
	}
	
	
	@:to static inline function toClassMap<K:Class<Dynamic>,V> (t:IMap<K, V>, weakKeys:Bool):ClassMap<K, V> {
		
		return new ClassMap<K, V> ();
		
	}
	
	
	@:from static inline function fromStringMap<V> (map:StringMap<V>):Dictionary<String, V> {
		
		return cast map;
		
	}
	
	
	@:from static inline function fromIntMap<V> (map:IntMap<V>):Dictionary<Int, V> {
		
		return cast map;
		
	}
	
	
	@:from static inline function fromObjectMap<K:{}, V> (map:ObjectMap<K, V>):Dictionary<K, V> {
		
		return cast map;
		
	}
	
	
	@:from static inline function fromUtilsObjectMap<K:Object, V> (map:UtilsObjectMap<K, V>):Dictionary<K, V> {
		
		return cast map;
		
	}
	
	
	@:from static inline function fromClassMap<K:Class<Dynamic>, V> (map:ClassMap<K, V>):Dictionary<K, V> {
		
		return cast map;
		
	}
	
	
}


#else


abstract Dictionary <K, V> (flash.utils.Dictionary) from flash.utils.Dictionary to flash.utils.Dictionary {
	
	
	public function new (weakKeys:Bool = false) {
		
		this = new flash.utils.Dictionary (weakKeys);
		
	}
	
	
	public inline function exists (key:K):Bool {
		
		return (untyped this[key] != untyped __global__["undefined"]);
		
	}
	
	
	@:arrayAccess public inline function get (key:K):V {
		
		return untyped this[key];
		
	}
	
	
	public inline function remove (key:K):Bool {
		
		var exists = (this:Dictionary<K, V>).exists (key);
		untyped __delete__ (this, key);
		return exists;
		
	}
	
	
	@:arrayAccess public inline function set (key:K, value:V):V {
		
		return untyped this[key] = value;
		
	}
	
	
	public inline function iterator ():Iterator<K> {
		
		return untyped __keys__ (this).iterator ();
		
	}
	
	
}


#end


@:dox(hide) private class ClassMap<K:Class<Dynamic>, V> implements Map.IMap<K, V> {
	
	
	private var types:Map<String, K>;
	private var values:Map<String, V>;
	
	
	public function new ():Void {
		
		types = new Map ();
		values = new Map ();
		
	}
	
	
	public function exists (key:K):Bool {
		
		return types.exists (Type.getClassName (key));
		
	}
	
	
	public function get (key:K):Null<V> {<commit_msg>Add `dictionary.each ()` for simulating `for each` behavior<commit_after>package openfl.utils; #if (!flash || display)


import haxe.ds.StringMap;
import haxe.ds.IntMap;
import haxe.ds.HashMap;
import haxe.ds.ObjectMap;
import haxe.ds.WeakMap;
import haxe.ds.EnumValueMap;
import haxe.Constraints.IMap;

@:multiType(K)


abstract Dictionary<K, V> (IMap<K, V>) {
	
	
	public function new (weakKeys:Bool = false);
	
	
	public inline function exists (key:K):Bool {
		
		return this.exists (key);
		
	}
	
	
	@:arrayAccess public inline function get (key:K):V {
		
		return this.get (key);
		
	}
	
	
	public inline function remove (key:K):Bool {
		
		return this.remove (key);
		
	}
	
	
	@:arrayAccess public inline function set (key:K, value:V):V {
		
		this.set (key, value);
		return value;
		
	}
	
	
	public inline function iterator ():Iterator<K> {
		
		return this.keys ();
		
	}
	
	
	public inline function each ():Iterator<V> {
		
		return this.iterator ();
		
	}
	
	
	@:to static inline function toStringMap<K:String, V> (t:IMap<K, V>, weakKeys:Bool):StringMap<V> {
		
		return new StringMap<V> ();
		
	}
	
	
	@:to static inline function toIntMap<K:Int, V> (t:IMap<K, V>, weakKeys:Bool):IntMap<V> {
		
		return new IntMap<V> ();
		
	}
	
	
	@:to static inline function toEnumValueMapMap<K:EnumValue, V> (t:IMap<K, V>, weakKeys:Bool):EnumValueMap<K, V> {
		
		return new EnumValueMap<K, V> ();
		
	}
	
	
	@:to static inline function toObjectMap<K:{},V> (t:IMap<K, V>, weakKeys:Bool):ObjectMap<K, V> {
		
		return new ObjectMap<K, V> ();
		
	}
	
	
	@:to static inline function toUtilsObjectMap<K:Object,V> (t:IMap<K, V>, weakKeys:Bool):UtilsObjectMap<K, V> {
		
		return new UtilsObjectMap<K, V> ();
		
	}
	
	
	@:to static inline function toClassMap<K:Class<Dynamic>,V> (t:IMap<K, V>, weakKeys:Bool):ClassMap<K, V> {
		
		return new ClassMap<K, V> ();
		
	}
	
	
	@:from static inline function fromStringMap<V> (map:StringMap<V>):Dictionary<String, V> {
		
		return cast map;
		
	}
	
	
	@:from static inline function fromIntMap<V> (map:IntMap<V>):Dictionary<Int, V> {
		
		return cast map;
		
	}
	
	
	@:from static inline function fromObjectMap<K:{}, V> (map:ObjectMap<K, V>):Dictionary<K, V> {
		
		return cast map;
		
	}
	
	
	@:from static inline function fromUtilsObjectMap<K:Object, V> (map:UtilsObjectMap<K, V>):Dictionary<K, V> {
		
		return cast map;
		
	}
	
	
	@:from static inline function fromClassMap<K:Class<Dynamic>, V> (map:ClassMap<K, V>):Dictionary<K, V> {
		
		return cast map;
		
	}
	
	
}


#else


abstract Dictionary <K, V> (flash.utils.Dictionary) from flash.utils.Dictionary to flash.utils.Dictionary {
	
	
	public function new (weakKeys:Bool = false) {
		
		this = new flash.utils.Dictionary (weakKeys);
		
	}
	
	
	public inline function exists (key:K):Bool {
		
		return (untyped this[key] != untyped __global__["undefined"]);
		
	}
	
	
	@:arrayAccess public inline function get (key:K):V {
		
		return untyped this[key];
		
	}
	
	
	public inline function remove (key:K):Bool {
		
		var exists = (this:Dictionary<K, V>).exists (key);
		untyped __delete__ (this, key);
		return exists;
		
	}
	
	
	@:arrayAccess public inline function set (key:K, value:V):V {
		
		return untyped this[key] = value;
		
	}
	
	
	public inline function iterator ():Iterator<K> {
		
		return untyped __keys__ (this).iterator ();
		
	}
	
	
	public inline function each ():Iterator<V> {
		
		return this.iterator ();
		
	}
	
	
}


#end


@:dox(hide) private class ClassMap<K:Class<Dynamic>, V> implements Map.IMap<K, V> {
	
	
	private var types:Map<String, K>;
	private var values:Map<String, V>;
	
	
	public function new ():Void {
		
		types = new Map ();
		values = new Map ();
		
	}
	
	
	public function exists (key:K):Bool {
		
		return types.exists (Type.getClassName (key));
		
	}
	
	
	public function get (key:K):Null<V> {
{'fraction_non_alphanumeric': 0.1438447221483648, 'fraction_numerical': 0.0, 'mean_word_length': 3.4462174940898347, 'pattern_counts': {'":': 0, '<': 112, '<?xml version=': 0, '>': 112, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4409624', 'n_tokens_mistral': 3142, 'n_tokens_neox': 2627, 'n_words': 667}