Class BitKey.AbstractBitKey

    • Constructor Detail

      • AbstractBitKey

        public AbstractBitKey()
    • Method Detail

      • bit

        protected static long bit​(int pos)
        Creates a chunk containing a single bit.
      • chunkPos

        protected static int chunkPos​(int size)
        Returns which chunk a given bit falls into. Bits 0 to 63 fall in chunk 0, bits 64 to 127 fall into chunk 1.
      • chunkCount

        protected static int chunkCount​(int size)
        Returns the number of chunks required for a given number of bits.

        0 bits requires 0 chunks; 1 - 64 bits requires 1 chunk; etc.

      • bitCount

        protected static int bitCount​(long i)
        Returns the number of one-bits in the two's complement binary representation of the specified long value. This function is sometimes referred to as the population count.

        (Copied from Long.bitCount(long), which was introduced in JDK 1.5, but we need the functionality in JDK 1.4.)

        Returns:
        the number of one-bits in the two's complement binary representation of the specified long value.
        Since:
        1.5
      • set

        public final void set​(int pos,
                              boolean value)
        Description copied from interface: BitKey
        Sets the bit at the specified index to the specified value.
        Specified by:
        set in interface BitKey
      • copyFromByte

        protected static void copyFromByte​(BitSet bitSet,
                                           int pos,
                                           byte x)
        Copies a byte into a bit set at a particular position.
        Parameters:
        bitSet - Bit set
        pos - Position
        x - Byte
      • copyFromLong

        protected static void copyFromLong​(BitSet bitSet,
                                           int pos,
                                           long x)
        Copies a long value (interpreted as 64 bits) into a bit set.
        Parameters:
        bitSet - Bit set
        pos - Position
        x - Byte