fill out the FuzzyMap API to match Map

This commit is contained in:
2021-12-21 15:48:22 -07:00
parent 5db920d39e
commit 6af947ff8d

View File

@@ -4,7 +4,7 @@ import haxe.ds.StringMap;
using hx.strings.Strings;
// TODO forward and implement the full Map API
@:forward(clear, copy, iterator, keyValueIterator, keys, toString)
abstract FuzzyMap<T>(StringMap<T>) from StringMap<T> to StringMap<T> {
public inline function new(?m:StringMap<T>) {
this = if (m != null) m else new StringMap<T>();
@@ -60,6 +60,10 @@ abstract FuzzyMap<T>(StringMap<T>) from StringMap<T> to StringMap<T> {
return this.remove(key);
}
public inline function exists(fuzzySearchKey:String):Bool {
return bestMatch(fuzzySearchKey, false) != null;
}
@:arrayAccess
public inline function set(key:String, v:T):T {
this.set(key, v);