Exemplo n.º 1
0
        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];
            }
        }
Exemplo n.º 2
0
 public ulong GetField(int n)
 {
     Pre.Assert(n >= 0, n);
     Pre.Assert(n < (Capacity / BitfieldSize), n);
     return(_bitfield[n]);
 }
Exemplo n.º 3
0
 public void Initialize(int capacity = 4)
 {
     Pre.Assert(Data == null);
     Data = new T[capacity];
 }