Class PackedBitArrays

java.lang.Object
net.algart.arrays.PackedBitArrays

public class PackedBitArrays extends Object

Operations with bit arrays packed into long[] Java arrays.

AlgART bits arrays, created by SimpleMemoryModel, are based on operations provided by this class.

The maximal length of bit arrays supported by this class is 237-64. All indexes and lengths passed to methods of this class must not exceed this value. Moreover, all indexes and length, concerning usual (non-packed) Java array, must not exceed 231-1. In other case, the results are unspecified. ("Unspecified" means that any elements of the passed arrays can be read or changed, or that IndexOutOfBoundsException can be thrown.)

In all methods of this class, it's supposed that the bit #k in a packed long[] array is the bit #(k%64) in the long element array[k/64]. In other words, the bit #k (false or true value) can be extracted by the following operator:

 (array[k >>> 6] & (1L << (k & 63))) != 0L
 

and can be set or cleared by the following operators:

 if (newValue) // we need to set bit #k to 1
     array[k >>> 6] |= 1L << (k & 63);
 else          // we need to clear bit #k to 0
     array[k >>> 6] &= ~(1L << (k & 63));
 

If any method of this class modifies some portion of an element of a packed long[] Java array, i.e. modifies less than all 64 its bits, then all accesses to this long element are performed inside a single synchronized block, using the following instruction:

 synchronized (array) {
     // accessing to some element array[k]
 }
 

(See an example in comments to setBit(long[], long, boolean) method.) If all 64 bits of the element are written, or if the bits are read only, then no synchronization is performed. Such behavior allows to simultaneously work with non-overlapping fragments of a packed bit array from several threads (different fragments for different threads), as if it would be a usual Java array.

This class cannot be instantiated.

Author:
Daniel Alievsky
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addBitsToInts(int[] dest, int destPos, long[] src, long srcPos, int count)
    Unpacks count bits, packed in src array, starting from the bit #srcPos, and add them count elements of dest array, starting from the element #destPos.
    static void
    andBits(long[] dest, long destPos, long[] src, long srcPos, long count)
    Replaces count bits, packed in dest array, starting from the bit #destPos, with the logical AND of them and corresponding count bits, packed in src array, starting from the bit #srcPos.
    static void
    andNotBits(long[] dest, long destPos, long[] src, long srcPos, long count)
    Replaces count bits, packed in dest array, starting from the bit #destPos, with the logical AND of them and inverted corresponding count bits, packed in src array, starting from the bit #srcPos.
    static boolean
    areBitsZero(long[] array, long pos, long count)
    Returns true if the specified fragment of the given packed bit array is filled by zero bits (0).
    static boolean
    bitEquals(long[] array1, long pos1, long[] array2, long pos2, long length)
    Returns true if the specified fragments of the given packed bit arrays are equals, or if both arguments are null.
    static int
    bitHashCode(long[] array, long fromIndex, long toIndex)
    Returns a hash code based on the contents of the specified fragment of the given packed bit array.
    static long
    cardinality(long[] src, long fromIndex, long toIndex)
    Returns the number of high bits (1) in the given fragment of the given packed bit array.
    static void
    copyBits(long[] dest, long destPos, long[] src, long srcPos, long count)
    Copies count bits, packed in src array, starting from the bit #srcPos, to packed dest array, starting from the bit #destPos.
    static void
    fillBits(long[] dest, long destPos, long count, boolean value)
    Fills count bits in the packed dest array, starting from the bit #destPos, by the specified value.
    static boolean
    getBit(long[] src, long index)
    Returns the bit #index in the packed src bit array.
    static long
    indexOfBit(long[] src, long lowIndex, long highIndex, boolean value)
    Returns the minimal index k, so that lowIndex<=k<highIndex and the bit #k in the packed src bit array is equal to value, or -1 if there is no such bits.
    static long
    lastIndexOfBit(long[] src, long lowIndex, long highIndex, boolean value)
    Returns the maximal index k, so that highIndex>k>=lowIndex and the bit #k in the packed src bit array is equal to value, or -1 if there is no such bits.
    static void
    notBits(long[] dest, long destPos, long[] src, long srcPos, long count)
    Replaces count bits, packed in dest array, starting from the bit #destPos, with the logical NOT of corresponding count bits, packed in src array, starting from the bit #srcPos.
    static void
    orBits(long[] dest, long destPos, long[] src, long srcPos, long count)
    Replaces count bits, packed in dest array, starting from the bit #destPos, with the logical OR of them and corresponding count bits, packed in src array, starting from the bit #srcPos.
    static void
    orNotBits(long[] dest, long destPos, long[] src, long srcPos, long count)
    Replaces count bits, packed in dest array, starting from the bit #destPos, with the logical OR of them and inverted corresponding count bits, packed in src array, starting from the bit #srcPos.
    static void
    packBits(long[] dest, long destPos, boolean[] src, int srcPos, int count)
    Copies count bits from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos.
    static void
    packBitsGreater(long[] dest, long destPos, byte[] src, int srcPos, int count, int threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFF) > threshold.
    static void
    packBitsGreater(long[] dest, long destPos, char[] src, int srcPos, int count, char threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] > threshold.
    static void
    packBitsGreater(long[] dest, long destPos, double[] src, int srcPos, int count, double threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] > threshold.
    static void
    packBitsGreater(long[] dest, long destPos, float[] src, int srcPos, int count, float threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] > threshold.
    static void
    packBitsGreater(long[] dest, long destPos, int[] src, int srcPos, int count, int threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] > threshold.
    static void
    packBitsGreater(long[] dest, long destPos, long[] src, int srcPos, int count, long threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] > threshold.
    static void
    packBitsGreater(long[] dest, long destPos, short[] src, int srcPos, int count, int threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFFFF) > threshold.
    static void
    packBitsGreaterOrEqual(long[] dest, long destPos, byte[] src, int srcPos, int count, int threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFF) >= threshold.
    static void
    packBitsGreaterOrEqual(long[] dest, long destPos, char[] src, int srcPos, int count, char threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] >= threshold.
    static void
    packBitsGreaterOrEqual(long[] dest, long destPos, double[] src, int srcPos, int count, double threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] >= threshold.
    static void
    packBitsGreaterOrEqual(long[] dest, long destPos, float[] src, int srcPos, int count, float threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] >= threshold.
    static void
    packBitsGreaterOrEqual(long[] dest, long destPos, int[] src, int srcPos, int count, int threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] >= threshold.
    static void
    packBitsGreaterOrEqual(long[] dest, long destPos, long[] src, int srcPos, int count, long threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] >= threshold.
    static void
    packBitsGreaterOrEqual(long[] dest, long destPos, short[] src, int srcPos, int count, int threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFFFF) >= threshold.
    static void
    packBitsInverted(long[] dest, long destPos, boolean[] src, int srcPos, int count)
    Copies count inverted bits from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos.
    static void
    packBitsLess(long[] dest, long destPos, byte[] src, int srcPos, int count, int threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFF) < threshold.
    static void
    packBitsLess(long[] dest, long destPos, char[] src, int srcPos, int count, char threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] < threshold.
    static void
    packBitsLess(long[] dest, long destPos, double[] src, int srcPos, int count, double threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] < threshold.
    static void
    packBitsLess(long[] dest, long destPos, float[] src, int srcPos, int count, float threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] < threshold.
    static void
    packBitsLess(long[] dest, long destPos, int[] src, int srcPos, int count, int threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] < threshold.
    static void
    packBitsLess(long[] dest, long destPos, long[] src, int srcPos, int count, long threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] < threshold.
    static void
    packBitsLess(long[] dest, long destPos, short[] src, int srcPos, int count, int threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFFFF) < threshold.
    static void
    packBitsLessOrEqual(long[] dest, long destPos, byte[] src, int srcPos, int count, int threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFF) <= threshold.
    static void
    packBitsLessOrEqual(long[] dest, long destPos, char[] src, int srcPos, int count, char threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] <= threshold.
    static void
    packBitsLessOrEqual(long[] dest, long destPos, double[] src, int srcPos, int count, double threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] <= threshold.
    static void
    packBitsLessOrEqual(long[] dest, long destPos, float[] src, int srcPos, int count, float threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] <= threshold.
    static void
    packBitsLessOrEqual(long[] dest, long destPos, int[] src, int srcPos, int count, int threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] <= threshold.
    static void
    packBitsLessOrEqual(long[] dest, long destPos, long[] src, int srcPos, int count, long threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] <= threshold.
    static void
    packBitsLessOrEqual(long[] dest, long destPos, short[] src, int srcPos, int count, int threshold)
    Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFFFF) <= threshold.
    static long
    packedLength(long unpackedLength)
    Returns (unpackedLength + 63) >>> 6: the minimal number of long values allowing to store unpackedLength bits.
    static void
    reverseBitsOrder(long[] dest, long destPos, long[] src, long srcPos, long count)
    Reverse order of count bits, packed in src array, starting from the bit #srcPos, and puts the result into dest array, starting from the bit #destPos.
    static void
    setBit(long[] dest, long index, boolean value)
    Sets the bit #index in the packed dest bit array.
    static void
    unpackBits(boolean[] dest, int destPos, long[] src, long srcPos, int count)
    Copies count bits, packed in src array, starting from the bit #srcPos, to dest boolean array, starting from the element #destPos.
    static void
    unpackBits(boolean[] dest, int destPos, long[] src, long srcPos, int count, boolean bit0Value, boolean bit1Value)
    Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest boolean array, starting from the element #destPos.
    static void
    unpackBits(byte[] dest, int destPos, long[] src, long srcPos, int count, byte bit0Value, byte bit1Value)
    Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest byte array, starting from the element #destPos.
    static void
    unpackBits(char[] dest, int destPos, long[] src, long srcPos, int count, char bit0Value, char bit1Value)
    Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest char array, starting from the element #destPos.
    static void
    unpackBits(double[] dest, int destPos, long[] src, long srcPos, int count, double bit0Value, double bit1Value)
    Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest double array, starting from the element #destPos.
    static void
    unpackBits(float[] dest, int destPos, long[] src, long srcPos, int count, float bit0Value, float bit1Value)
    Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest float array, starting from the element #destPos.
    static void
    unpackBits(int[] dest, int destPos, long[] src, long srcPos, int count, int bit0Value, int bit1Value)
    Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest int array, starting from the element #destPos.
    static void
    unpackBits(long[] dest, int destPos, long[] src, long srcPos, int count, long bit0Value, long bit1Value)
    Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest long array, starting from the element #destPos.
    static void
    unpackBits(short[] dest, int destPos, long[] src, long srcPos, int count, short bit0Value, short bit1Value)
    Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest short array, starting from the element #destPos.
    static void
    unpackBits(Object[] dest, int destPos, long[] src, long srcPos, int count, Object bit0Value, Object bit1Value)
    Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest Object array, starting from the element #destPos.
    static void
    unpackUnitBits(boolean[] dest, int destPos, long[] src, long srcPos, int count, boolean bit1Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest boolean array, starting from the element #destPos, to bit1Value.
    static void
    unpackUnitBits(byte[] dest, int destPos, long[] src, long srcPos, int count, byte bit1Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest byte array, starting from the element #destPos, to bit1Value.
    static void
    unpackUnitBits(char[] dest, int destPos, long[] src, long srcPos, int count, char bit1Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest char array, starting from the element #destPos, to bit1Value.
    static void
    unpackUnitBits(double[] dest, int destPos, long[] src, long srcPos, int count, double bit1Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest double array, starting from the element #destPos, to bit1Value.
    static void
    unpackUnitBits(float[] dest, int destPos, long[] src, long srcPos, int count, float bit1Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest float array, starting from the element #destPos, to bit1Value.
    static void
    unpackUnitBits(int[] dest, int destPos, long[] src, long srcPos, int count, int bit1Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest int array, starting from the element #destPos, to bit1Value.
    static void
    unpackUnitBits(long[] dest, int destPos, long[] src, long srcPos, int count, long bit1Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest long array, starting from the element #destPos, to bit1Value.
    static void
    unpackUnitBits(short[] dest, int destPos, long[] src, long srcPos, int count, short bit1Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest short array, starting from the element #destPos, to bit1Value.
    static void
    unpackUnitBits(Object[] dest, int destPos, long[] src, long srcPos, int count, Object bit1Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest Object array, starting from the element #destPos, to bit1Value.
    static void
    unpackZeroBits(boolean[] dest, int destPos, long[] src, long srcPos, int count, boolean bit0Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest boolean array, starting from the element #destPos, to bit0Value.
    static void
    unpackZeroBits(byte[] dest, int destPos, long[] src, long srcPos, int count, byte bit0Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest byte array, starting from the element #destPos, to bit0Value.
    static void
    unpackZeroBits(char[] dest, int destPos, long[] src, long srcPos, int count, char bit0Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest char array, starting from the element #destPos, to bit0Value.
    static void
    unpackZeroBits(double[] dest, int destPos, long[] src, long srcPos, int count, double bit0Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest double array, starting from the element #destPos, to bit0Value.
    static void
    unpackZeroBits(float[] dest, int destPos, long[] src, long srcPos, int count, float bit0Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest float array, starting from the element #destPos, to bit0Value.
    static void
    unpackZeroBits(int[] dest, int destPos, long[] src, long srcPos, int count, int bit0Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest int array, starting from the element #destPos, to bit0Value.
    static void
    unpackZeroBits(long[] dest, int destPos, long[] src, long srcPos, int count, long bit0Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest long array, starting from the element #destPos, to bit0Value.
    static void
    unpackZeroBits(short[] dest, int destPos, long[] src, long srcPos, int count, short bit0Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest short array, starting from the element #destPos, to bit0Value.
    static void
    unpackZeroBits(Object[] dest, int destPos, long[] src, long srcPos, int count, Object bit0Value)
    Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest Object array, starting from the element #destPos, to bit0Value.
    static void
    updateBitHashCode(long[] array, long fromIndex, long toIndex, Checksum hash)
    Updates hash code (hash argument) on the base of the contents of the specified fragment of the given packed bit array.
    static void
    xorBits(long[] dest, long destPos, long[] src, long srcPos, long count)
    Replaces count bits, packed in dest array, starting from the bit #destPos, with the logical XOR of them and corresponding count bits, packed in src array, starting from the bit #srcPos.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • packedLength

      public static long packedLength(long unpackedLength)
      Returns (unpackedLength + 63) >>> 6: the minimal number of long values allowing to store unpackedLength bits.
      Parameters:
      unpackedLength - the number of bits (the length of bit array).
      Returns:
      (unpackedLength + 63) >>> 6 (the length of corresponding long[] array).
    • getBit

      public static boolean getBit(long[] src, long index)
      Returns the bit #index in the packed src bit array. Equivalent to the following expression:
       (src[(int)(index >>> 6)] & (1L << (index & 63))) != 0L;
       
      Parameters:
      src - the source array (bits are packed in long values).
      index - index of the returned bit.
      Returns:
      the bit at the specified index.
      Throws:
      NullPointerException - if src is null.
      IndexOutOfBoundsException - if this method cause access of data outside array bounds.
    • setBit

      public static void setBit(long[] dest, long index, boolean value)
      Sets the bit #index in the packed dest bit array. Equivalent to the following operators:
       synchronized (dest) {
           if (value)
               dest[(int)(index >>> 6)] |= 1L << (index & 63);
           else
               dest[(int)(index >>> 6)] &= ~(1L << (index & 63));
       }
       
      Parameters:
      dest - the destination array (bits are packed in long values).
      index - index of the written bit.
      value - new bit value.
      Throws:
      NullPointerException - if dest is null.
      IndexOutOfBoundsException - if this method cause access of data outside array bounds.
    • bitHashCode

      public static int bitHashCode(long[] array, long fromIndex, long toIndex)
      Returns a hash code based on the contents of the specified fragment of the given packed bit array. If the passed array is null or fromIndex==toIndex, returns 0.

      The returned hash code depends only on the sequence of packed bits, but does not depend on the position of this sequence in the passed long[] array.

      For any two packed bit arrays a1 and a2 such that PackedBitArrays.bitEquals(a1, pos1, a2, pos2, count), it is also the case that PackedBitArrays.bitHashCode(a1, pos1, pos1 + count) == PackedBitArrays.bitHashCode(a2, pos2, pos2 + count).

      Parameters:
      array - the packed bit array whose content-based hash code to compute.
      fromIndex - the initial index of the checked fragment, inclusive.
      toIndex - the end index of the checked fragment, exclusive.
      Returns:
      a content-based hash code for the specified fragment in array.
      Throws:
      IllegalArgumentException - if the array argument is not a Java array.
      IndexOutOfBoundsException - if fromIndex or toIndex are negative, if toIndex is greater than array.length*64 (0 if array==null), or if fromIndex is greater than startIndex, or if array==null and not fromIndex==toIndex==0
      See Also:
    • updateBitHashCode

      public static void updateBitHashCode(long[] array, long fromIndex, long toIndex, Checksum hash)
      Updates hash code (hash argument) on the base of the contents of the specified fragment of the given packed bit array. If the passed array is null or fromIndex==toIndex, does nothing.

      This method is used by bitHashCode(long[] array, long fromIndex, long toIndex). More precisely, that method is equivalent to:

       Checksum sum = new CRC32();
       updateBitHashCode(array, fromIndex, toIndex, sum);
       return fromIndex == toIndex ? 0 : (int)sum.getValue();
       

      The following 2 code fragment always produce the same results in hashargument:

       updateBitHashCode(arr, fromIndex, toIndex, hash);
       
      and
       updateBitHashCode(arr, fromIndex, k1, hash);
       updateBitHashCode(arr, k1, k2, hash);
       ...
       updateBitHashCode(arr, kN, toIndex, hash);
       
      where fromIndex <= k1 <= k2 <= ... <= kN <= toIndex. So, unlike bitHashCode, this method allows to calculate correct hash code of a long array when we cannot get all its element at the same time, but can get sequent portions ot it.
      Parameters:
      array - the packed bit array whose content-based hash code to compute.
      fromIndex - the initial index of the checked fragment, inclusive.
      toIndex - the end index of the checked fragment, exclusive.
      hash - updated hash code.
      Throws:
      NullPointerException - if array is null.
      IndexOutOfBoundsException - if fromIndex or toIndex are negative, if toIndex is greater than array.length (0 if array==null), or if fromIndex is greater than startIndex, or if array==null and not fromIndex==toIndex==0
    • bitEquals

      public static boolean bitEquals(long[] array1, long pos1, long[] array2, long pos2, long length)
      Returns true if the specified fragments of the given packed bit arrays are equals, or if both arguments are null. Returns false if one of the arguments is null, but the other is not null.

      The two packed bit arrays are considered equal if all corresponding pairs of bits in the two arrays are equal.

      Parameters:
      array1 - one array to be tested for equality.
      pos1 - the initial index of the checked fragment in the first array.
      array2 - the other array to be tested for equality.
      pos2 - the initial index of the checked fragment in the second array.
      length - the number of compared elements.
      Returns:
      true if the specified fragments of two arrays are equal.
      Throws:
      IllegalArgumentException - if the array1 or array2 argument is not a Java array.
      IndexOutOfBoundsException - if pos1, pos2 or length are negative, if pos1 + length is greater than array1.length*64 (0 if array1==null), or if pos2 + length is greater than array2.length*64 (0 if array2==null).
    • copyBits

      public static void copyBits(long[] dest, long destPos, long[] src, long srcPos, long count)
      Copies count bits, packed in src array, starting from the bit #srcPos, to packed dest array, starting from the bit #destPos.

      This method works correctly even if src == dest and the copied areas overlap, i.e. if Math.abs(destPos - srcPos) < count. More precisely, in this case the copying is performed as if the bits at positions srcPos..srcPos+count-1 were first unpacked to a temporary boolean[] array with count elements and then the contents of the temporary array were packed into positions destPos..destPos+count-1.

      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be copied (must be >=0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBits

      public static void packBits(long[] dest, long destPos, boolean[] src, int srcPos, int count)
      Copies count bits from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked boolean values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsInverted

      public static void packBitsInverted(long[] dest, long destPos, boolean[] src, int srcPos, int count)
      Copies count inverted bits from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked inverted boolean values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsGreater

      public static void packBitsGreater(long[] dest, long destPos, char[] src, int srcPos, int count, char threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] > threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked char values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are greater than this value are packed to unit bits (1), the source elements less than or equal to this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsLess

      public static void packBitsLess(long[] dest, long destPos, char[] src, int srcPos, int count, char threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] < threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked char values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are less than to this value are packed to unit bits (1), the source elements greater than or equal this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsGreaterOrEqual

      public static void packBitsGreaterOrEqual(long[] dest, long destPos, char[] src, int srcPos, int count, char threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] >= threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked char values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are greater than or equal to this value are packed to unit bits (1), the source elements less than this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsLessOrEqual

      public static void packBitsLessOrEqual(long[] dest, long destPos, char[] src, int srcPos, int count, char threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] <= threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked char values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are less than or equal to this value are packed to unit bits (1), the source elements greater than this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsGreater

      public static void packBitsGreater(long[] dest, long destPos, byte[] src, int srcPos, int count, int threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFF) > threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked byte values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are greater than this value are packed to unit bits (1), the source elements less than or equal to this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsLess

      public static void packBitsLess(long[] dest, long destPos, byte[] src, int srcPos, int count, int threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFF) < threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked byte values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are less than to this value are packed to unit bits (1), the source elements greater than or equal this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsGreaterOrEqual

      public static void packBitsGreaterOrEqual(long[] dest, long destPos, byte[] src, int srcPos, int count, int threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFF) >= threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked byte values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are greater than or equal to this value are packed to unit bits (1), the source elements less than this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsLessOrEqual

      public static void packBitsLessOrEqual(long[] dest, long destPos, byte[] src, int srcPos, int count, int threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFF) <= threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked byte values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are less than or equal to this value are packed to unit bits (1), the source elements greater than this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsGreater

      public static void packBitsGreater(long[] dest, long destPos, short[] src, int srcPos, int count, int threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFFFF) > threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked short values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are greater than this value are packed to unit bits (1), the source elements less than or equal to this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsLess

      public static void packBitsLess(long[] dest, long destPos, short[] src, int srcPos, int count, int threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFFFF) < threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked short values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are less than to this value are packed to unit bits (1), the source elements greater than or equal this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsGreaterOrEqual

      public static void packBitsGreaterOrEqual(long[] dest, long destPos, short[] src, int srcPos, int count, int threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFFFF) >= threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked short values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are greater than or equal to this value are packed to unit bits (1), the source elements less than this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsLessOrEqual

      public static void packBitsLessOrEqual(long[] dest, long destPos, short[] src, int srcPos, int count, int threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value (src[k] & 0xFFFF) <= threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked short values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are less than or equal to this value are packed to unit bits (1), the source elements greater than this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsGreater

      public static void packBitsGreater(long[] dest, long destPos, int[] src, int srcPos, int count, int threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] > threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked int values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are greater than this value are packed to unit bits (1), the source elements less than or equal to this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsLess

      public static void packBitsLess(long[] dest, long destPos, int[] src, int srcPos, int count, int threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] < threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked int values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are less than to this value are packed to unit bits (1), the source elements greater than or equal this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsGreaterOrEqual

      public static void packBitsGreaterOrEqual(long[] dest, long destPos, int[] src, int srcPos, int count, int threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] >= threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked int values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are greater than or equal to this value are packed to unit bits (1), the source elements less than this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsLessOrEqual

      public static void packBitsLessOrEqual(long[] dest, long destPos, int[] src, int srcPos, int count, int threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] <= threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked int values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are less than or equal to this value are packed to unit bits (1), the source elements greater than this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsGreater

      public static void packBitsGreater(long[] dest, long destPos, long[] src, int srcPos, int count, long threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] > threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked long values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are greater than this value are packed to unit bits (1), the source elements less than or equal to this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsLess

      public static void packBitsLess(long[] dest, long destPos, long[] src, int srcPos, int count, long threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] < threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked long values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are less than to this value are packed to unit bits (1), the source elements greater than or equal this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsGreaterOrEqual

      public static void packBitsGreaterOrEqual(long[] dest, long destPos, long[] src, int srcPos, int count, long threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] >= threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked long values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are greater than or equal to this value are packed to unit bits (1), the source elements less than this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsLessOrEqual

      public static void packBitsLessOrEqual(long[] dest, long destPos, long[] src, int srcPos, int count, long threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] <= threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked long values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are less than or equal to this value are packed to unit bits (1), the source elements greater than this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsGreater

      public static void packBitsGreater(long[] dest, long destPos, float[] src, int srcPos, int count, float threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] > threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked float values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are greater than this value are packed to unit bits (1), the source elements less than or equal to this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsLess

      public static void packBitsLess(long[] dest, long destPos, float[] src, int srcPos, int count, float threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] < threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked float values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are less than to this value are packed to unit bits (1), the source elements greater than or equal this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsGreaterOrEqual

      public static void packBitsGreaterOrEqual(long[] dest, long destPos, float[] src, int srcPos, int count, float threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] >= threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked float values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are greater than or equal to this value are packed to unit bits (1), the source elements less than this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsLessOrEqual

      public static void packBitsLessOrEqual(long[] dest, long destPos, float[] src, int srcPos, int count, float threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] <= threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked float values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are less than or equal to this value are packed to unit bits (1), the source elements greater than this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsGreater

      public static void packBitsGreater(long[] dest, long destPos, double[] src, int srcPos, int count, double threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] > threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked double values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are greater than this value are packed to unit bits (1), the source elements less than or equal to this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsLess

      public static void packBitsLess(long[] dest, long destPos, double[] src, int srcPos, int count, double threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] < threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked double values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are less than to this value are packed to unit bits (1), the source elements greater than or equal this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsGreaterOrEqual

      public static void packBitsGreaterOrEqual(long[] dest, long destPos, double[] src, int srcPos, int count, double threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] >= threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked double values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are greater than or equal to this value are packed to unit bits (1), the source elements less than this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • packBitsLessOrEqual

      public static void packBitsLessOrEqual(long[] dest, long destPos, double[] src, int srcPos, int count, double threshold)
      Packs count elements from src array, starting from the element #srcPos, to packed dest array, starting from the bit #destPos, so that every element src[k] is transformed to boolean (bit) value src[k] <= threshold.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (unpacked double values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be packed (must be >=0).
      threshold - the source elements that are less than or equal to this value are packed to unit bits (1), the source elements greater than this threshold are packed to zero bits (0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackBits

      public static void unpackBits(boolean[] dest, int destPos, long[] src, long srcPos, int count)
      Copies count bits, packed in src array, starting from the bit #srcPos, to dest boolean array, starting from the element #destPos.
      Parameters:
      dest - the destination array (unpacked boolean values).
      destPos - position of the first written bit in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be unpacked (must be >=0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackBits

      public static void unpackBits(boolean[] dest, int destPos, long[] src, long srcPos, int count, boolean bit0Value, boolean bit1Value)
      Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest boolean array, starting from the element #destPos. It means that every element dest[destPos+k] is assigned to getBit(srcPos+k)?bit1Value:bit0Value.
      Parameters:
      dest - the destination array (unpacked boolean values).
      destPos - position of the first written element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements in the destination array to which the bit 0 is translated.
      bit1Value - the value of elements in the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackUnitBits

      public static void unpackUnitBits(boolean[] dest, int destPos, long[] src, long srcPos, int count, boolean bit1Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest boolean array, starting from the element #destPos, to bit1Value. Elements of dest array, corresponding to zero bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?bit1Value:dest[destPos+k].
      Parameters:
      dest - the destination array (unpacked boolean values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit1Value - the value of elements of the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackZeroBits

      public static void unpackZeroBits(boolean[] dest, int destPos, long[] src, long srcPos, int count, boolean bit0Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest boolean array, starting from the element #destPos, to bit0Value. Elements of dest array, corresponding to unit bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?dest[destPos+k]:bit0Value.
      Parameters:
      dest - the destination array (unpacked boolean values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements of the destination array to which the bit 0 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackBits

      public static void unpackBits(char[] dest, int destPos, long[] src, long srcPos, int count, char bit0Value, char bit1Value)
      Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest char array, starting from the element #destPos. It means that every element dest[destPos+k] is assigned to getBit(srcPos+k)?bit1Value:bit0Value.
      Parameters:
      dest - the destination array (unpacked char values).
      destPos - position of the first written element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements in the destination array to which the bit 0 is translated.
      bit1Value - the value of elements in the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackUnitBits

      public static void unpackUnitBits(char[] dest, int destPos, long[] src, long srcPos, int count, char bit1Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest char array, starting from the element #destPos, to bit1Value. Elements of dest array, corresponding to zero bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?bit1Value:dest[destPos+k].
      Parameters:
      dest - the destination array (unpacked char values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit1Value - the value of elements of the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackZeroBits

      public static void unpackZeroBits(char[] dest, int destPos, long[] src, long srcPos, int count, char bit0Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest char array, starting from the element #destPos, to bit0Value. Elements of dest array, corresponding to unit bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?dest[destPos+k]:bit0Value.
      Parameters:
      dest - the destination array (unpacked char values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements of the destination array to which the bit 0 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackBits

      public static void unpackBits(byte[] dest, int destPos, long[] src, long srcPos, int count, byte bit0Value, byte bit1Value)
      Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest byte array, starting from the element #destPos. It means that every element dest[destPos+k] is assigned to getBit(srcPos+k)?bit1Value:bit0Value.
      Parameters:
      dest - the destination array (unpacked byte values).
      destPos - position of the first written element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements in the destination array to which the bit 0 is translated.
      bit1Value - the value of elements in the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackUnitBits

      public static void unpackUnitBits(byte[] dest, int destPos, long[] src, long srcPos, int count, byte bit1Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest byte array, starting from the element #destPos, to bit1Value. Elements of dest array, corresponding to zero bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?bit1Value:dest[destPos+k].
      Parameters:
      dest - the destination array (unpacked byte values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit1Value - the value of elements of the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackZeroBits

      public static void unpackZeroBits(byte[] dest, int destPos, long[] src, long srcPos, int count, byte bit0Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest byte array, starting from the element #destPos, to bit0Value. Elements of dest array, corresponding to unit bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?dest[destPos+k]:bit0Value.
      Parameters:
      dest - the destination array (unpacked byte values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements of the destination array to which the bit 0 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackBits

      public static void unpackBits(short[] dest, int destPos, long[] src, long srcPos, int count, short bit0Value, short bit1Value)
      Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest short array, starting from the element #destPos. It means that every element dest[destPos+k] is assigned to getBit(srcPos+k)?bit1Value:bit0Value.
      Parameters:
      dest - the destination array (unpacked short values).
      destPos - position of the first written element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements in the destination array to which the bit 0 is translated.
      bit1Value - the value of elements in the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackUnitBits

      public static void unpackUnitBits(short[] dest, int destPos, long[] src, long srcPos, int count, short bit1Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest short array, starting from the element #destPos, to bit1Value. Elements of dest array, corresponding to zero bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?bit1Value:dest[destPos+k].
      Parameters:
      dest - the destination array (unpacked short values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit1Value - the value of elements of the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackZeroBits

      public static void unpackZeroBits(short[] dest, int destPos, long[] src, long srcPos, int count, short bit0Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest short array, starting from the element #destPos, to bit0Value. Elements of dest array, corresponding to unit bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?dest[destPos+k]:bit0Value.
      Parameters:
      dest - the destination array (unpacked short values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements of the destination array to which the bit 0 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackBits

      public static void unpackBits(int[] dest, int destPos, long[] src, long srcPos, int count, int bit0Value, int bit1Value)
      Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest int array, starting from the element #destPos. It means that every element dest[destPos+k] is assigned to getBit(srcPos+k)?bit1Value:bit0Value.
      Parameters:
      dest - the destination array (unpacked int values).
      destPos - position of the first written element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements in the destination array to which the bit 0 is translated.
      bit1Value - the value of elements in the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackUnitBits

      public static void unpackUnitBits(int[] dest, int destPos, long[] src, long srcPos, int count, int bit1Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest int array, starting from the element #destPos, to bit1Value. Elements of dest array, corresponding to zero bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?bit1Value:dest[destPos+k].
      Parameters:
      dest - the destination array (unpacked int values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit1Value - the value of elements of the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackZeroBits

      public static void unpackZeroBits(int[] dest, int destPos, long[] src, long srcPos, int count, int bit0Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest int array, starting from the element #destPos, to bit0Value. Elements of dest array, corresponding to unit bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?dest[destPos+k]:bit0Value.
      Parameters:
      dest - the destination array (unpacked int values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements of the destination array to which the bit 0 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackBits

      public static void unpackBits(long[] dest, int destPos, long[] src, long srcPos, int count, long bit0Value, long bit1Value)
      Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest long array, starting from the element #destPos. It means that every element dest[destPos+k] is assigned to getBit(srcPos+k)?bit1Value:bit0Value.
      Parameters:
      dest - the destination array (unpacked long values).
      destPos - position of the first written element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements in the destination array to which the bit 0 is translated.
      bit1Value - the value of elements in the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackUnitBits

      public static void unpackUnitBits(long[] dest, int destPos, long[] src, long srcPos, int count, long bit1Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest long array, starting from the element #destPos, to bit1Value. Elements of dest array, corresponding to zero bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?bit1Value:dest[destPos+k].
      Parameters:
      dest - the destination array (unpacked long values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit1Value - the value of elements of the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackZeroBits

      public static void unpackZeroBits(long[] dest, int destPos, long[] src, long srcPos, int count, long bit0Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest long array, starting from the element #destPos, to bit0Value. Elements of dest array, corresponding to unit bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?dest[destPos+k]:bit0Value.
      Parameters:
      dest - the destination array (unpacked long values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements of the destination array to which the bit 0 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackBits

      public static void unpackBits(float[] dest, int destPos, long[] src, long srcPos, int count, float bit0Value, float bit1Value)
      Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest float array, starting from the element #destPos. It means that every element dest[destPos+k] is assigned to getBit(srcPos+k)?bit1Value:bit0Value.
      Parameters:
      dest - the destination array (unpacked float values).
      destPos - position of the first written element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements in the destination array to which the bit 0 is translated.
      bit1Value - the value of elements in the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackUnitBits

      public static void unpackUnitBits(float[] dest, int destPos, long[] src, long srcPos, int count, float bit1Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest float array, starting from the element #destPos, to bit1Value. Elements of dest array, corresponding to zero bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?bit1Value:dest[destPos+k].
      Parameters:
      dest - the destination array (unpacked float values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit1Value - the value of elements of the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackZeroBits

      public static void unpackZeroBits(float[] dest, int destPos, long[] src, long srcPos, int count, float bit0Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest float array, starting from the element #destPos, to bit0Value. Elements of dest array, corresponding to unit bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?dest[destPos+k]:bit0Value.
      Parameters:
      dest - the destination array (unpacked float values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements of the destination array to which the bit 0 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackBits

      public static void unpackBits(double[] dest, int destPos, long[] src, long srcPos, int count, double bit0Value, double bit1Value)
      Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest double array, starting from the element #destPos. It means that every element dest[destPos+k] is assigned to getBit(srcPos+k)?bit1Value:bit0Value.
      Parameters:
      dest - the destination array (unpacked double values).
      destPos - position of the first written element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements in the destination array to which the bit 0 is translated.
      bit1Value - the value of elements in the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackUnitBits

      public static void unpackUnitBits(double[] dest, int destPos, long[] src, long srcPos, int count, double bit1Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest double array, starting from the element #destPos, to bit1Value. Elements of dest array, corresponding to zero bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?bit1Value:dest[destPos+k].
      Parameters:
      dest - the destination array (unpacked double values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit1Value - the value of elements of the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackZeroBits

      public static void unpackZeroBits(double[] dest, int destPos, long[] src, long srcPos, int count, double bit0Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest double array, starting from the element #destPos, to bit0Value. Elements of dest array, corresponding to unit bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?dest[destPos+k]:bit0Value.
      Parameters:
      dest - the destination array (unpacked double values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements of the destination array to which the bit 0 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackBits

      public static void unpackBits(Object[] dest, int destPos, long[] src, long srcPos, int count, Object bit0Value, Object bit1Value)
      Unpacks count bits, packed in src array, starting from the bit #srcPos, to dest Object array, starting from the element #destPos. It means that every element dest[destPos+k] is assigned to getBit(srcPos+k)?bit1Value:bit0Value.
      Parameters:
      dest - the destination array (unpacked Object values).
      destPos - position of the first written element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements in the destination array to which the bit 0 is translated.
      bit1Value - the value of elements in the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackUnitBits

      public static void unpackUnitBits(Object[] dest, int destPos, long[] src, long srcPos, int count, Object bit1Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 1 sets the corresponding element of dest Object array, starting from the element #destPos, to bit1Value. Elements of dest array, corresponding to zero bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?bit1Value:dest[destPos+k].
      Parameters:
      dest - the destination array (unpacked Object values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit1Value - the value of elements of the destination array to which the bit 1 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • unpackZeroBits

      public static void unpackZeroBits(Object[] dest, int destPos, long[] src, long srcPos, int count, Object bit0Value)
      Tests count bits, packed in src array, starting from the bit #srcPos, and for every found bit 0 sets the corresponding element of dest Object array, starting from the element #destPos, to bit0Value. Elements of dest array, corresponding to unit bits of the source array, are not changed. In other words, every element dest[destPos+k] is assigned to new value getBit(srcPos+k)?dest[destPos+k]:bit0Value.
      Parameters:
      dest - the destination array (unpacked Object values).
      destPos - position of the first element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of elements to be unpacked (must be >=0).
      bit0Value - the value of elements of the destination array to which the bit 0 is translated.
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • addBitsToInts

      public static void addBitsToInts(int[] dest, int destPos, long[] src, long srcPos, int count)
      Unpacks count bits, packed in src array, starting from the bit #srcPos, and add them count elements of dest array, starting from the element #destPos. It means that every element dest[destPos+k] is assigned to dest[destPos+k]+(getBit(srcPos+k)?1:0).
      Parameters:
      dest - the destination array (unpacked int values).
      destPos - position of the first increased element in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be added to dest elements (must be >=0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if copying would cause access of data outside array bounds.
    • fillBits

      public static void fillBits(long[] dest, long destPos, long count, boolean value)
      Fills count bits in the packed dest array, starting from the bit #destPos, by the specified value. Be careful: the second int argument in this method is the number of filled element, but not the end filled index as in java.util.Arrays.fill methods.
      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      count - the number of bits to be filled (must be >=0).
      value - new value of all filled bits (false means the bit 0, true means the bit 1).
      Throws:
      NullPointerException - if dest is null.
      IndexOutOfBoundsException - if filling would cause access of data outside array bounds.
    • areBitsZero

      public static boolean areBitsZero(long[] array, long pos, long count)
      Returns true if the specified fragment of the given packed bit array is filled by zero bits (0). Returns false if at least one of count bits of this array, starting from the bit #pos, is 1.

      If the count argument (number of elements) is 0, this method returns true.

      Parameters:
      array - the checked bit array (bits are packed in long values).
      pos - the initial index of the checked fragment in the array.
      count - the number of checked bits.
      Returns:
      true if and only if all count bits, starting from the bit #pos, are zero, or if count==0.
      Throws:
      NullPointerException - if the array argument is null.
      IndexOutOfBoundsException - if checking would cause access of data outside array bounds.
    • notBits

      public static void notBits(long[] dest, long destPos, long[] src, long srcPos, long count)
      Replaces count bits, packed in dest array, starting from the bit #destPos, with the logical NOT of corresponding count bits, packed in src array, starting from the bit #srcPos.

      This method works correctly even if src == dest and srcPos == destPos: in this case it just inverts the specified bits.

      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be replaced (must be >=0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if accessing bits would cause access of data outside array bounds.
    • andBits

      public static void andBits(long[] dest, long destPos, long[] src, long srcPos, long count)
      Replaces count bits, packed in dest array, starting from the bit #destPos, with the logical AND of them and corresponding count bits, packed in src array, starting from the bit #srcPos.

      This method works correctly even if src == dest and srcPos == destPos: in this case it does nothing (so there are no reasons for this call).

      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be replaced (must be >=0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if accessing bits would cause access of data outside array bounds.
    • orBits

      public static void orBits(long[] dest, long destPos, long[] src, long srcPos, long count)
      Replaces count bits, packed in dest array, starting from the bit #destPos, with the logical OR of them and corresponding count bits, packed in src array, starting from the bit #srcPos.

      This method works correctly even if src == dest and srcPos == destPos: in this case it does nothing (so there are no reasons for this call).

      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be replaced (must be >=0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if accessing bits would cause access of data outside array bounds.
    • xorBits

      public static void xorBits(long[] dest, long destPos, long[] src, long srcPos, long count)
      Replaces count bits, packed in dest array, starting from the bit #destPos, with the logical XOR of them and corresponding count bits, packed in src array, starting from the bit #srcPos.

      This method works correctly even if src == dest and srcPos == destPos: in this case it clears all specified bits.

      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be replaced (must be >=0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if accessing bits would cause access of data outside array bounds.
    • andNotBits

      public static void andNotBits(long[] dest, long destPos, long[] src, long srcPos, long count)
      Replaces count bits, packed in dest array, starting from the bit #destPos, with the logical AND of them and inverted corresponding count bits, packed in src array, starting from the bit #srcPos.

      This method works correctly even if src == dest and srcPos == destPos: in this case it clears all specified bits.

      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be replaced (must be >=0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if accessing bits would cause access of data outside array bounds.
    • orNotBits

      public static void orNotBits(long[] dest, long destPos, long[] src, long srcPos, long count)
      Replaces count bits, packed in dest array, starting from the bit #destPos, with the logical OR of them and inverted corresponding count bits, packed in src array, starting from the bit #srcPos.

      This method works correctly even if src == dest and srcPos == destPos: in this case it sets all specified bits to 1.

      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be replaced (must be >=0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if accessing bits would cause access of data outside array bounds.
    • reverseBitsOrder

      public static void reverseBitsOrder(long[] dest, long destPos, long[] src, long srcPos, long count)
      Reverse order of count bits, packed in src array, starting from the bit #srcPos, and puts the result into dest array, starting from the bit #destPos. So, the bit #(destPos+k) in dest bit array will be equal to the bit #(srcPos+count-1-k) of the src bit array.

      This method does not work correctly if src == dest.

      Parameters:
      dest - the destination array (bits are packed in long values).
      destPos - position of the first written bit in the destination array.
      src - the source array (bits are packed in long values).
      srcPos - position of the first read bit in the source array.
      count - the number of bits to be replaced (must be >=0).
      Throws:
      NullPointerException - if either src or dest is null.
      IndexOutOfBoundsException - if accessing bits would cause access of data outside array bounds.
    • indexOfBit

      public static long indexOfBit(long[] src, long lowIndex, long highIndex, boolean value)
      Returns the minimal index k, so that lowIndex<=k<highIndex and the bit #k in the packed src bit array is equal to value, or -1 if there is no such bits.

      If lowIndex>=highIndex, this method returns -1.

      Parameters:
      src - the searched packed bit array.
      lowIndex - the low index for search (inclusive).
      highIndex - the high index for search (exclusive).
      value - the value of bit to be found.
      Returns:
      the index of the first occurrence of this bit in range lowIndex..highIndex-1, or -1 if this bit does not occur or if lowIndex>=highIndex.
      Throws:
      NullPointerException - if array is null.
      IndexOutOfBoundsException - if lowIndex is negative or if highIndex is greater than src.length*64.
      See Also:
    • lastIndexOfBit

      public static long lastIndexOfBit(long[] src, long lowIndex, long highIndex, boolean value)
      Returns the maximal index k, so that highIndex>k>=lowIndex and the bit #k in the packed src bit array is equal to value, or -1 if there is no such bits.

      If highIndex<=lowIndex, this method returns -1.

      Note that lowIndex and highIndex arguments have the same sense as in indexOfBit(long[], long, long, boolean) method: they describes the search index range lowIndex<=k<highIndex.

      Parameters:
      src - the searched packed bit array.
      lowIndex - the low index in the array for search (inclusive); pass 0 to search all remaining elements.
      highIndex - the high index in the array for search (exclusive).
      value - the value of bit to be found.
      Returns:
      the index of the last occurrence of this bit in range lowIndex..highIndex-1, or -1 if this bit does not occur or if lowIndex>=highIndex.
      Throws:
      NullPointerException - if src is null.
      IndexOutOfBoundsException - if lowIndex is negative or if highIndex is greater than src.length*64.
      See Also:
    • cardinality

      public static long cardinality(long[] src, long fromIndex, long toIndex)
      Returns the number of high bits (1) in the given fragment of the given packed bit array.
      Parameters:
      src - the source packed bit array.
      fromIndex - the initial checked bit index in array, inclusive.
      toIndex - the end checked bit index in array, exclusive.
      Returns:
      the number of high bits (1) in the given fragment of the given packed bit array.
      Throws:
      NullPointerException - if the src argument is null.
      IndexOutOfBoundsException - if fromIndex or toIndex are negative, if toIndex is greater than src.length*64, or if fromIndex is greater than startIndex