public static void Set(ref StructListStruct <T> list, int i, T newValue) { if (list.count - 1 < i || i < 0) { throw new IndexOutOfRangeException(); } list.data[i] = newValue; }
public static void Clear(ref StructListStruct <T> list) { T[] array = list.data; if (array != null) { Array.Clear(array, 0, list.count); list.count = 0; } }
public static void RemoveAt(ref StructListStruct <T> list, int i) { if (list.count - 1 < i || i < 0) { throw new IndexOutOfRangeException(); } list.count--; T[] array = list.data; Array.Copy(array, i + 1, array, i, list.count - i); array[list.count] = default(T); }
public static void Add(ref StructListStruct <T> list, T newValue) { list.count++; T[] array = list.data; if (array == null) { list.data = new T[16]; } else if (array.Length < list.count) { T[] newArray = new T[array.Length * 2]; Array.Copy(array, newArray, array.Length); list.data = newArray; } list.data[list.count - 1] = newValue; }