bitvector-jvm-0.1.4 / net.onedaybeard.bitvector / BitVector

BitVector

class BitVector : Iterable<Int> (source)

Performance optimized bitset implementation. Certain operations are prefixed with unsafe; these methods perform no validation.

Constructors

<init> BitVector()BitVector(copyFrom: BitVector)

Creates a bit set based off another bit vector.

Properties

isEmpty val isEmpty: Boolean
words var words: IntArray

(can be manipulated directly)

Functions

and fun and(other: BitVector): Unit

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.

andNot fun andNot(other: BitVector): Unit

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

cardinality fun cardinality(): Int

Returns the count of true bits

clear fun clear(index: Int): Unitfun clear(): Unit

Clears the entire bitset

contains operator fun contains(other: BitVector): Boolean

Returns true if this bit set is a super set of the specified set, i.e. it has all bits set to true that are also set to true in the specified BitVector.

copy fun copy(): BitVector
ensureCapacity fun ensureCapacity(bits: Int): Unit

Grows the backing array so that it can hold the requested bits. Mostly applicable when relying on the unsafe methods, including unsafeGet and unsafeClear.

equals fun equals(obj: Any?): Boolean
flip fun flip(index: Int): Unit
forEachBit fun forEachBit(f: (Int) -> Unit): Unit

Enumerates over all true bits sequeneially. This function performs better than forEach and any other functions from Iterable<Int>.

get operator fun get(index: Int): Boolean
hashCode fun hashCode(): Int
intersects fun intersects(other: BitVector): Boolean

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

iterator fun iterator(): IntIterator
length fun length(): Int

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.

or fun or(other: BitVector): Unit

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 fun set(index: Int): Unit
operator fun set(index: Int, value: Boolean): Unit
toString fun toString(): String
unsafeClear fun unsafeClear(index: Int): Unit
unsafeGet fun unsafeGet(index: Int): Boolean
unsafeSet fun unsafeSet(index: Int): Unit
fun unsafeSet(index: Int, value: Boolean): Unit
xor fun xor(other: BitVector): Unit

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: