Packages

class BitSetFX extends AbstractSet[Integer] with SortedSet[Integer] with Cloneable with Serializable

This class implements a vector of bits that grows as needed. Each component of the bit set has a boolean value. The bits of a BitSet are indexed by nonnegative integers. Individual indexed bits can be examined, set, or cleared. One BitSet may be used to modify the contents of another BitSet through logical AND, logical inclusive OR, and logical exclusive OR operations.

By default, all bits in the set initially have the value false.

Every bit set has a current size, which is the number of bits of space currently in use by the bit set. Note that the size is related to the implementation of a bit set, so it may change with implementation. The length of a bit set relates to logical length of a bit set and is defined independently of implementation.

Unless otherwise noted, passing a null parameter to any of the methods in a BitSet will result in a NullPointerException.

A BitSet is not safe for multithreaded use without external synchronization.

Since

JDK1.0

Linear Supertypes
Serializable, Cloneable, SortedSet[Integer], AbstractSet[Integer], Set[Integer], AbstractCollection[Integer], Collection[Integer], Iterable[Integer], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. BitSetFX
  2. Serializable
  3. Cloneable
  4. SortedSet
  5. AbstractSet
  6. Set
  7. AbstractCollection
  8. Collection
  9. Iterable
  10. AnyRef
  11. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new BitSetFX(c: Collection[_ <: Integer])
  2. new BitSetFX(b: BitSetFX)
  3. new BitSetFX(nbits: Int)

    Creates a bit set whose initial size is large enough to explicitly represent bits with indices in the range 0 through nbits-1.

    Creates a bit set whose initial size is large enough to explicitly represent bits with indices in the range 0 through nbits-1. All bits are initially false.

    nbits

    the initial size of the bit set

    Exceptions thrown

    NegativeArraySizeException if the specified initial size is negative

  4. new BitSetFX()

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def add(e: Integer): Boolean
    Definition Classes
    BitSetFX → Set → AbstractCollection → Collection
  5. def addAll(c: Collection[_ <: Integer]): Boolean
    Definition Classes
    BitSetFX → Set → AbstractCollection → Collection
  6. def addRange(start: Int, end: Int): Unit
  7. def and(sets: Collection[BitSetFX]): Unit
  8. def and(sets: <repeated...>[BitSetFX]): Unit
  9. def and(set: BitSetFX): Unit

    Performs a logical AND of this target bit set with the argument bit set.

    Performs a logical AND of this target bit set with the argument bit set. This bit set is modified so that each bit in it has the value true if and only if it both initially had the value true and the corresponding bit in the bit set argument also had the value true.

    set

    a bit set

  10. def andNot(set: BitSetFX): Unit

    Clears all of the bits in this BitSet whose corresponding bit is set in the specified BitSet.

    Clears all of the bits in this BitSet whose corresponding bit is set in the specified BitSet.

    set

    the BitSet with which to mask this BitSet

    Since

    1.2

  11. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  12. def cardinality(): Int

    Returns the number of bits set to true in this BitSet.

    Returns the number of bits set to true in this BitSet.

    returns

    the number of bits set to true in this BitSet

    Since

    1.4

  13. def clear(): Unit

    Sets all of the bits in this BitSet to false.

    Sets all of the bits in this BitSet to false.

    Definition Classes
    BitSetFX → Set → AbstractCollection → Collection
    Since

    1.4

  14. def clear(fromIndex: Int, toIndex: Int): Unit

    Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to false.

    Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to false.

    fromIndex

    index of the first bit to be cleared

    toIndex

    index after the last bit to be cleared

    Since

    1.4

    Exceptions thrown

    IndexOutOfBoundsException if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex

  15. def clear(bitIndex: Int): Unit

    Sets the bit specified by the index to false.

    Sets the bit specified by the index to false.

    bitIndex

    the index of the bit to be cleared

    Since

    JDK1.0

    Exceptions thrown

    IndexOutOfBoundsException if the specified index is negative

  16. def clone(): AnyRef

    Cloning this BitSet produces a new BitSet that is equal to it.

    Cloning this BitSet produces a new BitSet that is equal to it. The clone of the bit set is another bit set that has exactly the same bits set to true as this bit set.

    returns

    a clone of this bit set

    Definition Classes
    BitSetFX → AnyRef
    See also

    #space()

  17. def comparator(): Comparator[_ >: Integer]
    Definition Classes
    BitSetFX → SortedSet
  18. def contains(o: Any): Boolean
    Definition Classes
    BitSetFX → Set → AbstractCollection → Collection
  19. def containsAll(c: Collection[_]): Boolean
    Definition Classes
    BitSetFX → Set → AbstractCollection → Collection
  20. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. def equals(obj: Any): Boolean

    Compares this object against the specified object.

    Compares this object against the specified object. The result is true if and only if the argument is not null and is a Bitset object that has exactly the same set of bits set to true as this bit set. That is, for every nonnegative int index k,

    ((BitSet) obj).get(k) == this.get(k)
    

    must be true. The current sizes of the two bit sets are not compared.

    obj

    the object to compare with

    returns

    true if the objects are the same; false otherwise

    Definition Classes
    BitSetFX → AbstractSet → Set → Collection → AnyRef → Any
    See also

    #space()

  22. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  23. def first(): Integer
    Definition Classes
    BitSetFX → SortedSet
  24. def flip(fromIndex: Int, toIndex: Int): Unit

    Sets each bit from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to the complement of its current value.

    Sets each bit from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to the complement of its current value.

    fromIndex

    index of the first bit to flip

    toIndex

    index after the last bit to flip

    Since

    1.4

    Exceptions thrown

    IndexOutOfBoundsException if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex

  25. def flip(bitIndex: Int): Unit

    Sets the bit at the specified index to the complement of its current value.

    Sets the bit at the specified index to the complement of its current value.

    bitIndex

    the index of the bit to flip

    Since

    1.4

    Exceptions thrown

    IndexOutOfBoundsException if the specified index is negative

  26. def forEach(arg0: Consumer[_ >: Integer]): Unit
    Definition Classes
    Iterable
  27. def geq(set: BitSetFX): Boolean
  28. def get(fromIndex: Int, toIndex: Int): BitSetFX

    Returns a new BitSet composed of bits from this BitSet from fromIndex (inclusive) to toIndex (exclusive).

    Returns a new BitSet composed of bits from this BitSet from fromIndex (inclusive) to toIndex (exclusive).

    fromIndex

    index of the first bit to include

    toIndex

    index after the last bit to include

    returns

    a new BitSet from a range of this BitSet

    Since

    1.4

    Exceptions thrown

    IndexOutOfBoundsException if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex

  29. def get(bitIndex: Int): Boolean

    Returns the value of the bit with the specified index.

    Returns the value of the bit with the specified index. The value is true if the bit with the index bitIndex is currently set in this BitSet; otherwise, the result is false.

    bitIndex

    the bit index

    returns

    the value of the bit with the specified index

    Exceptions thrown

    IndexOutOfBoundsException if the specified index is negative

  30. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  31. def hashCode(): Int

    Returns the hash code value for this bit set.

    Returns the hash code value for this bit set. The hash code depends only on which bits are set within this BitSet.

    The hash code is defined to be the result of the following calculation:

     
    public int hashCode() {
        long h = 1234;
        long[] words = toLongArray();
        for (int i = words.length; --i >= 0; )
            h ^= words[i] * (i + 1);
        return (int)((h >> 32) ^ h);
    }
    

    Note that the hash code changes if the set of bits is altered.

    returns

    the hash code value for this bit set

    Definition Classes
    BitSetFX → AbstractSet → Set → Collection → AnyRef → Any
  32. def headSet(toElement: Integer): SortedSet[Integer]
    Definition Classes
    BitSetFX → SortedSet
  33. def intersects(set: BitSetFX): Boolean

    Returns true if the specified BitSet has any bits set to true that are also set to true in this BitSet.

    Returns true if the specified BitSet has any bits set to true that are also set to true in this BitSet.

    set

    BitSet to intersect with

    returns

    boolean indicating whether this BitSet intersects the specified BitSet

    Since

    1.4

  34. def isEmpty(): Boolean

    Returns true if this BitSet contains no bits that are set to true.

    Returns true if this BitSet contains no bits that are set to true.

    returns

    boolean indicating whether this BitSet is empty

    Definition Classes
    BitSetFX → Set → AbstractCollection → Collection
    Since

    1.4

  35. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  36. def iterator(): Iterator[Integer]
    Definition Classes
    BitSetFX → Set → AbstractCollection → Collection → Iterable
  37. def last(): Integer
    Definition Classes
    BitSetFX → SortedSet
  38. def length(): Int

    Returns the "logical size" of this BitSet: the index of the highest set bit in the BitSet plus one.

    Returns the "logical size" of this BitSet: the index of the highest set bit in the BitSet plus one. Returns zero if the BitSet contains no set bits.

    returns

    the logical size of this BitSet

    Since

    1.2

  39. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  40. def nextClearBit(fromIndex: Int): Int

    Returns the index of the first bit that is set to false that occurs on or after the specified starting index.

    Returns the index of the first bit that is set to false that occurs on or after the specified starting index.

    fromIndex

    the index to start checking from (inclusive)

    returns

    the index of the next clear bit

    Since

    1.4

    Exceptions thrown

    IndexOutOfBoundsException if the specified index is negative

  41. def nextSetBit(fromIndex: Int): Int

    Returns the index of the first bit that is set to true that occurs on or after the specified starting index.

    Returns the index of the first bit that is set to true that occurs on or after the specified starting index. If no such bit exists then -1 is returned.

    To iterate over the true bits in a BitSet, use the following loop:

     
    for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i+1)) {
        // operate on index i here
        if (i == Integer.MAX_VALUE) {
            break; // or (i+1) would overflow
        
    }}
    

    fromIndex

    the index to start checking from (inclusive)

    returns

    the index of the next set bit, or -1 if there is no such bit

    Since

    1.4

    Exceptions thrown

    IndexOutOfBoundsException if the specified index is negative

  42. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  43. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  44. def or(set: BitSetFX): Unit

    Performs a logical OR of this bit set with the bit set argument.

    Performs a logical OR of this bit set with the bit set argument. This bit set is modified so that a bit in it has the value true if and only if it either already had the value true or the corresponding bit in the bit set argument has the value true.

    set

    a bit set

  45. def parallelStream(): Stream[Integer]
    Definition Classes
    Collection
  46. def previousClearBit(fromIndex: Int): Int

    Returns the index of the nearest bit that is set to false that occurs on or before the specified starting index.

    Returns the index of the nearest bit that is set to false that occurs on or before the specified starting index. If no such bit exists, or if -1 is given as the starting index, then -1 is returned.

    fromIndex

    the index to start checking from (inclusive)

    returns

    the index of the previous clear bit, or -1 if there is no such bit

    Since

    1.7

    Exceptions thrown

    IndexOutOfBoundsException if the specified index is less than -1

  47. def previousSetBit(fromIndex: Int): Int

    Returns the index of the nearest bit that is set to true that occurs on or before the specified starting index.

    Returns the index of the nearest bit that is set to true that occurs on or before the specified starting index. If no such bit exists, or if -1 is given as the starting index, then -1 is returned.

    To iterate over the true bits in a BitSet, use the following loop:

     
    for (int i = bs.length(); (i = bs.previousSetBit(i-1)) >= 0; ) {
        // operate on index i here
    }
    

    fromIndex

    the index to start checking from (inclusive)

    returns

    the index of the previous set bit, or -1 if there is no such bit

    Since

    1.7

    Exceptions thrown

    IndexOutOfBoundsException if the specified index is less than -1

  48. def remove(o: Any): Boolean
    Definition Classes
    BitSetFX → Set → AbstractCollection → Collection
  49. def removeAll(c: Collection[_]): Boolean
    Definition Classes
    BitSetFX → AbstractSet → Set → AbstractCollection → Collection
  50. def removeIf(arg0: Predicate[_ >: Integer]): Boolean
    Definition Classes
    Collection
  51. def retainAll(c: Collection[_]): Boolean
    Definition Classes
    BitSetFX → Set → AbstractCollection → Collection
  52. def set(fromIndex: Int, toIndex: Int, value: Boolean): Unit

    Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to the specified value.

    Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to the specified value.

    fromIndex

    index of the first bit to be set

    toIndex

    index after the last bit to be set

    value

    value to set the selected bits to

    Since

    1.4

    Exceptions thrown

    IndexOutOfBoundsException if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex

  53. def set(fromIndex: Int, toIndex: Int): Unit

    Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to true.

    Sets the bits from the specified fromIndex (inclusive) to the specified toIndex (exclusive) to true.

    fromIndex

    index of the first bit to be set

    toIndex

    index after the last bit to be set

    Since

    1.4

    Exceptions thrown

    IndexOutOfBoundsException if fromIndex is negative, or toIndex is negative, or fromIndex is larger than toIndex

  54. def set(bitIndex: Int, value: Boolean): Unit

    Sets the bit at the specified index to the specified value.

    Sets the bit at the specified index to the specified value.

    bitIndex

    a bit index

    value

    a boolean value to set

    Since

    1.4

    Exceptions thrown

    IndexOutOfBoundsException if the specified index is negative

  55. def set(bitIndex: Int): Unit

    Sets the bit at the specified index to true.

    Sets the bit at the specified index to true.

    bitIndex

    a bit index

    Since

    JDK1.0

    Exceptions thrown

    IndexOutOfBoundsException if the specified index is negative

  56. def size(): Int
    Definition Classes
    BitSetFX → Set → AbstractCollection → Collection
  57. def space(): Int

    Returns the number of bits of space actually in use by this BitSet to represent bit values.

    Returns the number of bits of space actually in use by this BitSet to represent bit values. The maximum element in the set is the size - 1st element.

    returns

    the number of bits currently in this bit set

  58. def spliterator(): Spliterator[Integer]
    Definition Classes
    SortedSet → Set → Collection → Iterable
  59. def stream(): Stream[Integer]

    Returns a stream of indices for which this BitSet contains a bit in the set state.

    Returns a stream of indices for which this BitSet contains a bit in the set state. The indices are returned in order, from lowest to highest. The size of the stream is the number of bits in the set state, equal to the value returned by the #cardinality() method.

    The bit set must remain constant during the execution of the terminal stream operation. Otherwise, the result of the terminal stream operation is undefined.

    returns

    a stream of integers representing set indices

    Definition Classes
    BitSetFX → Collection
    Since

    1.8

  60. def subSet(fromElement: Integer, toElement: Integer): SortedSet[Integer]
    Definition Classes
    BitSetFX → SortedSet
  61. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  62. def tailSet(fromElement: Integer): SortedSet[Integer]
    Definition Classes
    BitSetFX → SortedSet
  63. def toArray[T](arg0: Array[T]): Array[T]
    Definition Classes
    AbstractCollection → Collection
  64. def toArray(): Array[AnyRef]
    Definition Classes
    AbstractCollection → Collection
  65. def toByteArray(): Array[Byte]

    Returns a new byte array containing all the bits in this bit set.

    Returns a new byte array containing all the bits in this bit set.

    More precisely, if
    byte[] bytes = s.toByteArray();
    then bytes.length == (s.length()+7)/8 and
    s.get(n) == ((bytes[n/8] & (1<<(n%8))) != 0)
    for all n < 8 * bytes.length.

    returns

    a byte array containing a little-endian representation of all the bits in this bit set

    Since

    1.7

  66. def toLongArray(): Array[Long]

    Returns a new long array containing all the bits in this bit set.

    Returns a new long array containing all the bits in this bit set.

    More precisely, if
    long[] longs = s.toLongArray();
    then longs.length == (s.length()+63)/64 and
    s.get(n) == ((longs[n/64] & (1L<<(n%64))) != 0)
    for all n < 64 * longs.length.

    returns

    a long array containing a little-endian representation of all the bits in this bit set

    Since

    1.7

  67. def toString(): String

    Returns a string representation of this bit set.

    Returns a string representation of this bit set. For every index for which this BitSet contains a bit in the set state, the decimal representation of that index is included in the result. Such indices are listed in order from lowest to highest, separated by ", " (a comma and a space) and surrounded by braces, resulting in the usual mathematical notation for a set of integers.

    Example:

    
    BitSet drPepper = new BitSet();
    

    Now drPepper.toString() returns "{}".

    drPepper.set(2);
    

    Now drPepper.toString() returns "{2}".

    drPepper.set(4);
    drPepper.set(10);
    

    Now drPepper.toString() returns "{2, 4, 10}".

    returns

    a string representation of this bit set

    Definition Classes
    BitSetFX → AbstractCollection → AnyRef → Any
  68. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  69. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  70. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  71. def xor(set: BitSetFX): Unit

    Performs a logical XOR of this bit set with the bit set argument.

    Performs a logical XOR of this bit set with the bit set argument. This bit set is modified so that a bit in it has the value true if and only if one of the following statements holds:

    • The bit initially has the value true, and the corresponding bit in the argument has the value false.
    • The bit initially has the value false, and the corresponding bit in the argument has the value true.
    set

    a bit set

Inherited from Serializable

Inherited from Cloneable

Inherited from SortedSet[Integer]

Inherited from AbstractSet[Integer]

Inherited from Set[Integer]

Inherited from AbstractCollection[Integer]

Inherited from Collection[Integer]

Inherited from Iterable[Integer]

Inherited from AnyRef

Inherited from Any

Ungrouped