public IEnumerable <T> Get(int amount) { if (pool.Length < amount) { int w = (pool.Length + 1) * 2; w = w - pool.Length > amount - pool.Length ? w : w + amount; Algs.IncreseArray(ref pool, w); for (int i = count; i < w; i++) { pool[i] = UnityEngine.GameObject.Instantiate(original); } } if (count > amount) { for (int i = count - 1; i > amount - 1; i--) { pool[i].gameObject.SetActive(false); } count = amount; } else if (count < amount) { for (; count < amount; count++) { pool[count].gameObject.SetActive(true); } } return(new ArrayProxy <T>(pool, 0, count)); }
public void Add(T item) { if (length == items.Length) { Algs.IncreseArray(ref items, (length + 1) * 2); } items[length++] = item; }
public T Get() { if (length == pool.Length) { Algs.IncreseArray(ref pool, (length + 1) * 2); InitNew(); } return(pool[length++]); }
public IEnumerable <T> Get(int amount) { if (length + amount - 1 >= pool.Length) { Algs.IncreseArray(ref pool, (length + amount) + (length + 1) * 2); InitNew(); } int begin = length; length += amount; return(new CustomEnumerable <T>(ResetAndGetEnumerator(begin))); }
public T Get() { if (length == pool.Length) { Algs.IncreseArray(ref pool, (length + 1) * 2); InitNew(); } var r = pool[length++]; r.Reset(); return(r); }
void Add(Tkey key, Tvalue value) { if (length == keys.Length) { Algs.IncreseArray(ref keys, (length + 1) * 2); Algs.IncreseArray(ref values, (length + 1) * 2); } keys[length] = key; values[length] = value; length++; }