public static EnsureCapacity ( |
||
bits | ||
numBits | long | |
Résultat |
public virtual void TestEnsureCapacity() { LongBitSet bits = new LongBitSet(5); bits.Set(1); bits.Set(4); LongBitSet newBits = LongBitSet.EnsureCapacity(bits, 8); // grow within the word Assert.IsTrue(newBits.Get(1)); Assert.IsTrue(newBits.Get(4)); newBits.Clear(1); // we align to 64-bits, so even though it shouldn't have, it re-allocated a long[1] Assert.IsTrue(bits.Get(1)); Assert.IsFalse(newBits.Get(1)); newBits.Set(1); newBits = LongBitSet.EnsureCapacity(newBits, newBits.Length() - 2); // reuse Assert.IsTrue(newBits.Get(1)); bits.Set(1); newBits = LongBitSet.EnsureCapacity(bits, 72); // grow beyond one word Assert.IsTrue(newBits.Get(1)); Assert.IsTrue(newBits.Get(4)); newBits.Clear(1); // we grew the long[], so it's not shared Assert.IsTrue(bits.Get(1)); Assert.IsFalse(newBits.Get(1)); }