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]); } }
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); }
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); }
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]); } } }
public static void RemoveRange <T>(this LiteList <T> c, int index, int count) { c._raw.RemoveRange(index, count); }
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)); }
public static int BinarySearch <T>(this LiteList <T> c, T item) { return(c._raw.BinarySearch(item)); }
public static void RemoveAt <T>(this LiteList <T> c, int index) { c._raw.RemoveAt(index); }
public static int LastIndexOf <T>(this LiteList <T> c, T item, int index, int count) { return(c._raw.LastIndexOf(item, index, count)); }
public static int LastIndexOf <T>(this LiteList <T> c, T item) { return(c._raw.LastIndexOf(item)); }
public static int BinarySearch <T>(this LiteList <T> c, T item, IComparer comparer) { return(c._raw.BinarySearch(item, comparer)); }
public static bool Contains <T>(this LiteList <T> c, T item) { return(c._raw.Contains(item)); }
public static void Add <T>(this LiteList <T> c, T item) { c._raw.Add(item); }
public static void Sort <T>(this LiteList <T> c) { c._raw.Sort(); }
public static void CopyTo <T>(this LiteList <T> c, T[] array) { c._raw.CopyTo(array); }
public static void CopyTo <T>(this LiteList <T> c, int index, T[] array, int arrayIndex, int count) { c._raw.CopyTo(index, array, arrayIndex, count); }
public static void CopyTo <T>(this LiteList <T> c, T[] array, int arrayIndex) { c._raw.CopyTo(array, arrayIndex); }
public static void Sort <T>(this LiteList <T> c, IComparer comparer) { c._raw.Sort(comparer); }
public static void InsertRange <T>(this LiteList <T> c, int index, ICollection collection) { c._raw.InsertRange(index, collection); }
public static void Sort <T>(this LiteList <T> c, int index, int count, IComparer comparer) { c._raw.Sort(index, count, comparer); }
public static void Clear <T>(this LiteList <T> c) { c._raw.Clear(); }
public static IEnumerator GetEnumerator <T>(this LiteList <T> c) { return(c._raw.GetEnumerator()); }
public static void Insert <T>(this LiteList <T> c, int index, T item) { c._raw.Insert(index, item); }
public static void AddRange <T>(this LiteList <T> c, ICollection collection) { c._raw.AddRange(collection); }
public static int IndexOf <T>(this LiteList <T> c, T item, int index) { return(c._raw.IndexOf(item, index)); }