Class BitMask

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class BitMask
    extends java.lang.Object
    implements java.lang.Cloneable
    • Constructor Summary

      Constructors 
      Constructor Description
      BitMask​(byte[] bytes, int numberOfBits)  
      BitMask​(byte[] bytes, int ones, int numberOfBits)  
      BitMask​(int numberOfBits)  
    • Constructor Detail

      • BitMask

        public BitMask​(byte[] bytes,
                       int ones,
                       int numberOfBits)
      • BitMask

        public BitMask​(byte[] bytes,
                       int numberOfBits)
      • BitMask

        public BitMask​(int numberOfBits)
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        The hashcode of BitMask is defined as the hashcode of its bytes.
        Overrides:
        hashCode in class java.lang.Object
      • set

        public void set​(int index,
                        boolean value)
      • getNumBytes

        public static int getNumBytes​(int size)
        returns the number of bytes in a bitmask for a list containing precisely size elements.
        Parameters:
        size -
        Returns:
      • makeBitMask

        public static BitMask makeBitMask​(int size,
                                          int... indices)
        Flag the bits at the given indices
        Parameters:
        indices -
      • makeBitMask

        public static BitMask makeBitMask​(int size,
                                          short... indices)
        Flag the bits at the given indices
        Parameters:
        indices -
      • makeBitMask

        public static BitMask makeBitMask​(int size,
                                          gnu.trove.set.TIntSet indices)
        Flag the bits at the given indices
        Parameters:
        indices -
      • makeBitMask

        public static BitMask makeBitMask​(int size,
                                          java.util.Collection<java.lang.Integer> indices)
        Flag the bits at the given indices
        Parameters:
        indices -
      • getIndices

        public static int[] getIndices​(BitMask bitmask)
        return the indices flagged by this bitmask
        Returns:
      • getOnes

        public int getOnes()
      • getBytes

        public byte[] getBytes()
      • getNumBits

        public int getNumBits()
      • toBooleanArray

        public boolean[] toBooleanArray()
      • clone

        public BitMask clone()
        Overrides:
        clone in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object