class BitSet extends AnyRef
This class represents either a table of bits or a set of non-negative numbers.
This class is integrated with the collection framework (as
a set of indices and obeys the collection semantic
for methods such as #size (cardinality) or #equals
(same set of indices).
- Version
5.3, February 24, 2008
- Alphabetic
- By Inheritance
- BitSet
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
BitSet(bitSize: Int)
Creates a bit set of specified initial capacity (in bits).
Creates a bit set of specified initial capacity (in bits). All bits are initially
false. This constructor reserves enough space to represent the integers from0tobitSize-1.- bitSize
the initial capacity in bits.
- new BitSet()
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
add(index: Index): Boolean
Adds the specified index to this set.
Adds the specified index to this set. This method is equivalent to
set(index.intValue()).- index
the integer value to be appended to this set.
- returns
trueif this set did not contains the specified index;falseotherwise.
-
def
and(that: BitSet): Unit
Performs the logical AND operation on this bit set and the given bit set.
Performs the logical AND operation on this bit set and the given bit set. This means it builds the intersection of the two sets. The result is stored into this bit set.
- that
the second bit set.
-
def
andNot(that: BitSet): Unit
Performs the logical AND operation on this bit set and the complement of the given bit set.
Performs the logical AND operation on this bit set and the complement of the given bit set. This means it selects every element in the first set, that isn't in the second set. The result is stored into this bit set.
- that
the second bit set
- def apply(bitIndex: Int): Boolean
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
cardinality(): Int
Returns the number of bits set to
true(or the size of this set).Returns the number of bits set to
true(or the size of this set).- returns
the number of bits being set.
-
def
clear(fromIndex: Int, toIndex: Int): Unit
Sets the bits from the specified
fromIndex(inclusive) to the specifiedtoIndex(exclusive) tofalse.Sets the bits from the specified
fromIndex(inclusive) to the specifiedtoIndex(exclusive) tofalse.- fromIndex
index of the first bit to be cleared.
- toIndex
index after the last bit to be cleared.
- Exceptions thrown
IndexOutOfBoundsExceptionif(fromIndex < 0) | (toIndex < fromIndex)
-
def
clear(bitIndex: Int): Unit
Removes the specified integer value from this set.
Removes the specified integer value from this set. That is the corresponding bit is cleared.
- bitIndex
a non-negative integer.
- Exceptions thrown
IndexOutOfBoundsExceptionifindex < 0
-
def
clear(): Unit
Sets all bits in the set to
false(empty the set). -
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- def contains(bitIndex: Int): Boolean
- def copy(): BitSet
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(obj: Any): Boolean
- Definition Classes
- BitSet → AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
flip(fromIndex: Int, toIndex: Int): Unit
Sets a range of bits to the opposite value.
Sets a range of bits to the opposite value.
- fromIndex
the low index (inclusive).
- toIndex
the high index (exclusive).
- Exceptions thrown
IndexOutOfBoundsExceptionif(fromIndex < 0) | (toIndex < fromIndex)
-
def
flip(bitIndex: Int): Unit
Sets the bit at the index to the opposite value.
Sets the bit at the index to the opposite value.
- bitIndex
the index of the bit.
- Exceptions thrown
IndexOutOfBoundsExceptionifbitIndex < 0
-
def
get(bitIndex: Int): Boolean
Returns
true> if the specified integer is in this bit set;falseotherwise.Returns
true> if the specified integer is in this bit set;falseotherwise.- bitIndex
a non-negative integer.
- returns
the value of the bit at the specified index.
- Exceptions thrown
IndexOutOfBoundsExceptionifbitIndex < 0
- def getBits(): Array[Long]
- def getBitsLength(): Int
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- BitSet → AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def length(): Int
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
nextClearBit(fromIndex: Int): Int
Returns the index of the next
falsebit, from the specified bit (inclusive).Returns the index of the next
falsebit, from the specified bit (inclusive).- fromIndex
the start location.
- returns
the first
falsebit.
- Exceptions thrown
IndexOutOfBoundsExceptioniffromIndex < 0
-
def
nextSetBit(fromIndex: Int): Int
Returns the index of the next
truebit, from the specified bit (inclusive).Returns the index of the next
truebit, from the specified bit (inclusive). If there is none,-1is returned. The following code will iterates through the bit set:[code] for (int i=nextSetBit(0); i >= 0; i = nextSetBit(i + 1)) { ... }[/code]- fromIndex
the start location.
- returns
the first
falsebit.
- Exceptions thrown
IndexOutOfBoundsExceptioniffromIndex < 0
- def nonEmpty(): Boolean
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
or(that: BitSet): Unit
Performs the logical OR operation on this bit set and the one specified.
Performs the logical OR operation on this bit set and the one specified. In other words, builds the union of the two sets. The result is stored into this bit set.
- that
the second bit set.
-
def
set(fromIndex: Int, toIndex: Int, value: Boolean): Unit
Sets the bits between from (inclusive) and to (exclusive) to the specified value.
Sets the bits between from (inclusive) and to (exclusive) to the specified value.
- fromIndex
the start range (inclusive).
- toIndex
the end range (exclusive).
- value
the value to set it to.
- Exceptions thrown
IndexOutOfBoundsExceptionifbitIndex < 0
-
def
set(fromIndex: Int, toIndex: Int): Unit
Sets the bits from the specified
fromIndex(inclusive) to the specifiedtoIndex(exclusive) totrue.Sets the bits from the specified
fromIndex(inclusive) to the specifiedtoIndex(exclusive) totrue.- fromIndex
index of the first bit to be set.
- toIndex
index after the last bit to be set.
- Exceptions thrown
IndexOutOfBoundsExceptionif(fromIndex < 0) | (toIndex < fromIndex)
-
def
set(bitIndex: Int, value: Boolean): Unit
Sets the bit at the given index to the specified value.
Sets the bit at the given index to the specified value.
- bitIndex
the position to set.
- value
the value to set it to.
- Exceptions thrown
IndexOutOfBoundsExceptionifbitIndex < 0
-
def
set(bitIndex: Int): Unit
Adds the specified integer to this set (corresponding bit is set to
true.Adds the specified integer to this set (corresponding bit is set to
true.- bitIndex
a non-negative integer.
- Exceptions thrown
IndexOutOfBoundsExceptionifbitIndex < 0
- def setBits(arr: Array[Long]): Unit
-
def
size(): Int
Returns the cardinality of this bit set (number of bits set).
Returns the cardinality of this bit set (number of bits set).
<P>Note: Unlike
java.util.BitSetthis method does not returns an approximation of the number of bits of space actually in use. This method is compliant with java.util.Collection meaning for size().- returns
the cardinality of this bit set.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
- def update(bitIndex: Int, value: Boolean): Unit
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
xor(that: BitSet): Unit
Performs the logical XOR operation on this bit set and the one specified.
Performs the logical XOR operation on this bit set and the one specified. In other words, builds the symmetric remainder of the two sets (the elements that are in one set, but not in the other). The result is stored into this bit set.
- that
the second bit set.