public void ReduceCapacity(int targetCapacity) { Pre.Assert(Data != null); Pre.Assert(targetCapacity >= Count, "Try using Reset first if you want to free all memory."); var oldCapacity = Data.Length; Pre.Assert(targetCapacity <= oldCapacity, "Use IncreaseCapacity to increase capacity."); if (targetCapacity == oldCapacity) { return; } DebugLogStupidAllocation(oldCapacity, targetCapacity); var oldArray = Data; Data = new T[targetCapacity]; for (var i = 0; i < targetCapacity; i++) { Data[i] = oldArray[i]; } }
public ulong GetField(int n) { Pre.Assert(n >= 0, n); Pre.Assert(n < (Capacity / BitfieldSize), n); return(_bitfield[n]); }
public void Initialize(int capacity = 4) { Pre.Assert(Data == null); Data = new T[capacity]; }