Class BooleanListBitVector

All Implemented Interfaces:
BitVector, BigList<Boolean>, BooleanBigList, BooleanCollection, BooleanIterable, BooleanStack, Size64, Stack<Boolean>, Serializable, Comparable<BigList<? extends Boolean>>, Iterable<Boolean>, Collection<Boolean>, RandomAccess

public class BooleanListBitVector extends AbstractBitVector implements Serializable
A boolean-list based implementation of BitVector.
See Also:
Implementation Notes:
This implementation of a bit vector is based on a backing list of booleans. It is rather inefficient, but useful for wrapping purposes, for covering completely the code in AbstractBitVector and for creating mock objects.
  • Constructor Details

    • BooleanListBitVector

      protected BooleanListBitVector(BooleanBigList list)
    • BooleanListBitVector

      protected BooleanListBitVector(int capacity)
  • Method Details

    • ensureIntegerIndex

      protected static final void ensureIntegerIndex(long index)
    • getInstance

      public static BooleanListBitVector getInstance(long capacity)
    • getInstance

      public static BooleanListBitVector getInstance()
      Creates a new empty bit vector.
    • of

      public static BooleanListBitVector of(int... bit)
      Creates a new bit vector with given bits.
    • wrap

      public static BooleanListBitVector wrap(BooleanList list)
    • wrap

      public static BooleanListBitVector wrap(BooleanBigList list)
    • length

      public long length()
      Description copied from interface: BitVector
      Returns the number of bits in this bit vector.

      If the number of bits in this bit vector is smaller than or equal to Integer.MAX_VALUE, this method is semantically equivalent to List.size(). In any case, this method is semantically equivalent to Size64.size64(), but it is prefererred.

      Specified by:
      length in interface BitVector
      Returns:
      the number of bits in this bit vector.
    • set

      public boolean set(long index, boolean value)
      Specified by:
      set in interface BooleanBigList
      Overrides:
      set in class AbstractBitVector
    • getBoolean

      public boolean getBoolean(long index)
      Specified by:
      getBoolean in interface BooleanBigList
    • add

      public void add(long index, boolean value)
      Specified by:
      add in interface BooleanBigList
      Overrides:
      add in class AbstractBitVector
    • removeBoolean

      public boolean removeBoolean(long index)
      Specified by:
      removeBoolean in interface BooleanBigList
      Overrides:
      removeBoolean in class AbstractBitVector
    • copy

      public BooleanListBitVector copy(long from, long to)
      Description copied from interface: BitVector
      Returns a copy of a part of this bit vector.
      Specified by:
      copy in interface BitVector
      Overrides:
      copy in class AbstractBitVector
      Parameters:
      from - the starting bit, inclusive.
      to - the ending bit, not inclusive.
      Returns:
      a copy of the part of this bit vector going from bit from (inclusive) to bit to (not inclusive)
    • copy

      public BooleanListBitVector copy()
      Description copied from interface: BitVector
      Returns a copy of this bit vector.
      Specified by:
      copy in interface BitVector
      Overrides:
      copy in class AbstractBitVector
      Returns:
      a copy of this bit vector.
    • ensureCapacity

      public BitVector ensureCapacity(long numBits)
    • length

      public BitVector length(long numBits)
      Description copied from interface: BitVector
      Sets the number of bits in this bit vector.

      It is expected that this method will try to allocate exactly the necessary space.

      If the argument fits an integer, this method has the same side effects of BooleanList.size(int). In any case, this method has the same side effects of BigList.size(long), but it is preferred, as it has the advantage of returning this bit vector, thus making it possible to chain methods.

      Specified by:
      length in interface BitVector
      Overrides:
      length in class AbstractBitVector
      Parameters:
      numBits - the new length in bits for this bit vector.
      Returns:
      this bit vector.