public static void RemoveIf <TKey, TValue>(this LiteMap <TKey, TValue> c, Func <TKey, TValue, bool> condition) { LiteList <TKey> tobeRemoved = null; var en = c.Keys.GetEnumerator(); while (en.MoveNext()) { TKey k = (TKey)en.Current; TValue v = (TValue)c[k]; if (condition(k, v)) { if (tobeRemoved == null) { tobeRemoved = new LiteList <TKey>(); } tobeRemoved.Add(k); } } if (tobeRemoved != null) { for (int i = 0; i < tobeRemoved.Count; i++) { c.Remove(tobeRemoved[i]); } } }
public static bool Remove <TKey, TValue>(this LiteMap <TKey, TValue> c, TKey key) { if (!c._raw.ContainsKey(key)) { return(false); } c._raw.Remove(key); return(true); }
public static void Foreach <TKey, TValue>(this LiteMap <TKey, TValue> c, Action <TKey, TValue> action) { var en = c.Keys.GetEnumerator(); while (en.MoveNext()) { TKey k = (TKey)en.Current; TValue v = (TValue)c[k]; action(k, v); } }
public static bool TryGetValue <TKey, TValue>(this LiteMap <TKey, TValue> c, TKey key, out TValue value) { value = default(TValue); if (!c.ContainsKey(key)) { return(false); } value = (TValue)c._raw[key]; return(true); }
public static IDictionaryEnumerator GetEnumerator <TKey, TValue>(this LiteMap <TKey, TValue> c) { return(c._raw.GetEnumerator()); }
public static bool ContainsValue <TKey, TValue>(this LiteMap <TKey, TValue> c, TValue value) { return(c._raw.ContainsValue(value)); }
public static bool ContainsKey <TKey, TValue>(this LiteMap <TKey, TValue> c, TKey key) { return(c._raw.ContainsKey(key)); }
public static void Clear <TKey, TValue>(this LiteMap <TKey, TValue> c) { c._raw.Clear(); }
public static void Add <TKey, TValue>(this LiteMap <TKey, TValue> c, TKey key, TValue value) { c._raw.Add(key, value); }