Пример #1
0
 /// <summary>
 /// If the given <see cref="Int64BitSet"/> is large enough to hold
 /// <paramref name="numBits"/>, returns the given <paramref name="bits"/>, otherwise returns a new
 /// <see cref="Int64BitSet"/> which can hold the requested number of bits.
 ///
 /// <para/>
 /// <b>NOTE:</b> the returned bitset reuses the underlying <see cref="T:long[]"/> of
 /// the given <paramref name="bits"/> if possible. Also, reading <see cref="Length"/> on the
 /// returned bits may return a value greater than <paramref name="numBits"/>.
 /// </summary>
 public static Int64BitSet EnsureCapacity(Int64BitSet bits, long numBits)
 {
     if (numBits < bits.Length)
     {
         return(bits);
     }
     else
     {
         int    numWords = Bits2words(numBits);
         long[] arr      = bits.GetBits();
         if (numWords >= arr.Length)
         {
             arr = ArrayUtil.Grow(arr, numWords + 1);
         }
         return(new Int64BitSet(arr, arr.Length << 6));
     }
 }