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 void Foreach <T>(this LiteList <T> c, Action <int, T> action)
 {
     for (int i = 0; i < c.Count; i++)
     {
         action(i, c[i]);
     }
 }
 public static void AddRange <T>(this LiteList <T> c, LiteList <T> collection)
 {
     for (int i = 0; i < collection.Count; i++)
     {
         c._raw.Add(collection._raw[i]);
     }
 }
Beispiel #4
0
        public static T[] ToArray <T>(this LiteList <T> c)
        {
            T[] result = new T[c.Count];
            for (int i = 0; i < c.Count; i++)
            {
                result[i] = c[i];
            }

            return(result);
        }
Beispiel #5
0
        public static bool Remove <T>(this LiteList <T> c, T item)
        {
            if (!c.Contains(item))
            {
                return(false);
            }

            c._raw.Remove(item);

            return(true);
        }
        public static LiteList <T> ToLiteList <T>(this IEnumerable <T> source)
        {
            LiteList <T> result = new LiteList <T>();

            foreach (var s in source)
            {
                result.Add(s);
            }

            return(result);
        }
Beispiel #7
0
        public static void Shuffle <T>(this LiteList <T> c)
        {
            Random rnd = new Random(Guid.NewGuid().GetHashCode());

            for (int k = 0; k < c.Count; k++)
            {
                int i = rnd.Next(0, c.Count - 1);
                int j = rnd.Next(0, c.Count - 1);
                T   t = c[i];
                c[i] = c[j];
                c[j] = t;
            }
        }
        public static LiteList <T> Shuffle <T>(this LiteList <T> c)
        {
            LiteList <T> l = new LiteList <T>();

            while (c.Count != 0)
            {
                int i = UnityEngine.Random.Range(0, c.Count - 1);
                l._raw.Add(c[i]);
                c._raw.RemoveAt(i);
            }

            return(l);
        }
        public static void RemoveIf <T>(this LiteList <T> c, Func <T, bool> condition)
        {
            LiteList <int> tobeRemoved = null;

            for (int i = c.Count - 1; i >= 0; i--)
            {
                T item = c[i];
                if (condition(item))
                {
                    if (tobeRemoved == null)
                    {
                        tobeRemoved = new LiteList <int>();
                    }
                    tobeRemoved.Add(i);
                }
            }
            if (tobeRemoved != null)
            {
                for (int i = 0; i < tobeRemoved.Count; i++)
                {
                    c.RemoveAt(tobeRemoved[i]);
                }
            }
        }
Beispiel #10
0
 public static void RemoveRange <T>(this LiteList <T> c, int index, int count)
 {
     c._raw.RemoveRange(index, count);
 }
Beispiel #11
0
 public static int BinarySearch <T>(this LiteList <T> c, int index, int count, T item, IComparer comparer)
 {
     return(c._raw.BinarySearch(index, count, item, comparer));
 }
Beispiel #12
0
 public static int BinarySearch <T>(this LiteList <T> c, T item)
 {
     return(c._raw.BinarySearch(item));
 }
Beispiel #13
0
 public static void RemoveAt <T>(this LiteList <T> c, int index)
 {
     c._raw.RemoveAt(index);
 }
Beispiel #14
0
 public static int LastIndexOf <T>(this LiteList <T> c, T item, int index, int count)
 {
     return(c._raw.LastIndexOf(item, index, count));
 }
Beispiel #15
0
 public static int LastIndexOf <T>(this LiteList <T> c, T item)
 {
     return(c._raw.LastIndexOf(item));
 }
Beispiel #16
0
 public static int BinarySearch <T>(this LiteList <T> c, T item, IComparer comparer)
 {
     return(c._raw.BinarySearch(item, comparer));
 }
Beispiel #17
0
 public static bool Contains <T>(this LiteList <T> c, T item)
 {
     return(c._raw.Contains(item));
 }
Beispiel #18
0
 public static void Add <T>(this LiteList <T> c, T item)
 {
     c._raw.Add(item);
 }
Beispiel #19
0
 public static void Sort <T>(this LiteList <T> c)
 {
     c._raw.Sort();
 }
Beispiel #20
0
 public static void CopyTo <T>(this LiteList <T> c, T[] array)
 {
     c._raw.CopyTo(array);
 }
Beispiel #21
0
 public static void CopyTo <T>(this LiteList <T> c, int index, T[] array, int arrayIndex, int count)
 {
     c._raw.CopyTo(index, array, arrayIndex, count);
 }
Beispiel #22
0
 public static void CopyTo <T>(this LiteList <T> c, T[] array, int arrayIndex)
 {
     c._raw.CopyTo(array, arrayIndex);
 }
Beispiel #23
0
 public static void Sort <T>(this LiteList <T> c, IComparer comparer)
 {
     c._raw.Sort(comparer);
 }
Beispiel #24
0
 public static void InsertRange <T>(this LiteList <T> c, int index, ICollection collection)
 {
     c._raw.InsertRange(index, collection);
 }
Beispiel #25
0
 public static void Sort <T>(this LiteList <T> c, int index, int count, IComparer comparer)
 {
     c._raw.Sort(index, count, comparer);
 }
Beispiel #26
0
 public static void Clear <T>(this LiteList <T> c)
 {
     c._raw.Clear();
 }
Beispiel #27
0
 public static IEnumerator GetEnumerator <T>(this LiteList <T> c)
 {
     return(c._raw.GetEnumerator());
 }
Beispiel #28
0
 public static void Insert <T>(this LiteList <T> c, int index, T item)
 {
     c._raw.Insert(index, item);
 }
Beispiel #29
0
 public static void AddRange <T>(this LiteList <T> c, ICollection collection)
 {
     c._raw.AddRange(collection);
 }
Beispiel #30
0
 public static int IndexOf <T>(this LiteList <T> c, T item, int index)
 {
     return(c._raw.IndexOf(item, index));
 }