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]);
                }
            }
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 public static IDictionaryEnumerator GetEnumerator <TKey, TValue>(this LiteMap <TKey, TValue> c)
 {
     return(c._raw.GetEnumerator());
 }
Beispiel #6
0
 public static bool ContainsValue <TKey, TValue>(this LiteMap <TKey, TValue> c, TValue value)
 {
     return(c._raw.ContainsValue(value));
 }
Beispiel #7
0
 public static bool ContainsKey <TKey, TValue>(this LiteMap <TKey, TValue> c, TKey key)
 {
     return(c._raw.ContainsKey(key));
 }
Beispiel #8
0
 public static void Clear <TKey, TValue>(this LiteMap <TKey, TValue> c)
 {
     c._raw.Clear();
 }
Beispiel #9
0
 public static void Add <TKey, TValue>(this LiteMap <TKey, TValue> c, TKey key, TValue value)
 {
     c._raw.Add(key, value);
 }