Class BitCounter

  • All Implemented Interfaces:
    BitmapStorage

    public final class BitCounter
    extends java.lang.Object
    implements BitmapStorage
    BitCounter is a fake bitset data structure. Instead of storing the actual data, it only records the number of set bits.
    Since:
    0.4.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int oneBits  
    • Constructor Summary

      Constructors 
      Constructor Description
      BitCounter()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addLiteralWord​(long newData)
      Virtually add literal words directly to the bitmap
      void addStreamOfEmptyWords​(boolean v, long number)
      virtually add many zeroes or ones.
      void addStreamOfLiteralWords​(Buffer buffer, int start, int number)
      virtually add several literal words.
      void addStreamOfNegatedLiteralWords​(Buffer buffer, int start, int number)
      virtually add several negated literal words.
      void addWord​(long newData)
      Virtually add words directly to the bitmap
      void clear()
      Empties the container.
      int getCount()
      As you act on this class, it records the number of set (true) bits.
      void setSizeInBitsWithinLastWord​(int bits)
      should directly set the sizeInBits field, but is effectively ignored in this class.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • oneBits

        private int oneBits
    • Constructor Detail

      • BitCounter

        public BitCounter()
    • Method Detail

      • addWord

        public void addWord​(long newData)
        Virtually add words directly to the bitmap
        Specified by:
        addWord in interface BitmapStorage
        Parameters:
        newData - the word
      • addLiteralWord

        public void addLiteralWord​(long newData)
        Virtually add literal words directly to the bitmap
        Specified by:
        addLiteralWord in interface BitmapStorage
        Parameters:
        newData - the word
      • addStreamOfLiteralWords

        public void addStreamOfLiteralWords​(Buffer buffer,
                                            int start,
                                            int number)
        virtually add several literal words.
        Specified by:
        addStreamOfLiteralWords in interface BitmapStorage
        Parameters:
        buffer - the buffer wrapping the literal words
        start - the starting point in the array
        number - the number of literal words to add
      • addStreamOfEmptyWords

        public void addStreamOfEmptyWords​(boolean v,
                                          long number)
        virtually add many zeroes or ones.
        Specified by:
        addStreamOfEmptyWords in interface BitmapStorage
        Parameters:
        v - zeros or ones
        number - how many to words add
      • addStreamOfNegatedLiteralWords

        public void addStreamOfNegatedLiteralWords​(Buffer buffer,
                                                   int start,
                                                   int number)
        virtually add several negated literal words.
        Specified by:
        addStreamOfNegatedLiteralWords in interface BitmapStorage
        Parameters:
        buffer - the buffer wrapping the literal words
        start - the starting point in the array
        number - the number of literal words to add
      • getCount

        public int getCount()
        As you act on this class, it records the number of set (true) bits.
        Returns:
        number of set bits
      • setSizeInBitsWithinLastWord

        public void setSizeInBitsWithinLastWord​(int bits)
        should directly set the sizeInBits field, but is effectively ignored in this class.
        Specified by:
        setSizeInBitsWithinLastWord in interface BitmapStorage
        Parameters:
        bits - number of bits