BitSet

Native
1.3
class BitSet

A vector of bits growing if necessary and allowing one to set/clear/read bits from it by a bit index.

Constructors

Native
1.3

<init>

Creates a bit set of given length filling elements using initializer

BitSet(length: Int, initializer: (Int) -> Boolean)

creates an empty bit set with the specified size

BitSet(size: Int = ELEMENT_SIZE)

Properties

Native
1.3

isEmpty

True if this BitSet contains no bits set to true.

val isEmpty: Boolean
Native
1.3

lastTrueIndex

Returns an index of the last bit that has true value. Returns -1 if the set is empty.

val lastTrueIndex: Int
Native
1.3

size

Actual number of bits available in the set. All bits with indices >= size assumed to be 0

var size: Int

Functions

Native
1.3

and

Performs a logical and operation over corresponding bits of this and another BitSets. The result is saved in this BitSet.

fun and(another: BitSet)
Native
1.3

andNot

Performs a logical and + not operations over corresponding bits of this and another BitSets. The result is saved in this BitSet.

fun andNot(another: BitSet)
Native
1.3

clear

Clears the bit specified

fun clear(index: Int)
fun clear(range: IntRange)

Clears the bits with indices between from (inclusive) and to (exclusive) to the specified value.

fun clear(from: Int, to: Int)

Sets all bits in the BitSet to false.

fun clear()
Native
1.3

equals

Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements:

fun equals(other: Any?): Boolean
Native
1.3

flip

Reverses the bit specified.

fun flip(index: Int)

Reverses the bits with indices between from (inclusive) and to (exclusive).

fun flip(from: Int, to: Int)

Reverses the bits from the range specified.

fun flip(range: IntRange)
Native
1.3

get

Returns a value of a bit with the index specified.

operator fun get(index: Int): Boolean
Native
1.3

hashCode

Returns a hash code value for the object. The general contract of hashCode is:

fun hashCode(): Int
Native
1.3

intersects

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

fun intersects(another: BitSet): Boolean
Native
1.3

nextClearBit

Returns an index of a next bit which value is false after startIndex (inclusive). Returns size if there is no such bits between startIndex and size - 1 assuming that the set has an infinite sequence of false bits after (size - 1)-th.

fun nextClearBit(startIndex: Int = 0): Int
Native
1.3

nextSetBit

Returns an index of a next bit which value is true after startIndex (inclusive). Returns -1 if there is no such bits after startIndex.

fun nextSetBit(startIndex: Int = 0): Int
Native
1.3

or

Performs a logical or operation over corresponding bits of this and another BitSets. The result is saved in this BitSet.

fun or(another: BitSet)
Native
1.3

previousBit

Returns the biggest index of a bit which value is lookFor before startIndex (inclusive). Returns -1 if there is no such bits before startIndex. If startIndex >= size returns -1

fun previousBit(startIndex: Int, lookFor: Boolean): Int
Native
1.3

previousClearBit

Returns the biggest index of a bit which value is false before startIndex (inclusive). Returns -1 if there is no such bits before startIndex or if startIndex == -1. If startIndex >= size will return startIndex assuming that the set has an infinite sequence of false bits after (size - 1)-th.

fun previousClearBit(startIndex: Int): Int
Native
1.3

previousSetBit

Returns the biggest index of a bit which value is true before startIndex (inclusive). Returns -1 if there is no such bits before startIndex or if startIndex == -1. If startIndex >= size will search from (size - 1)-th bit.

fun previousSetBit(startIndex: Int): Int
Native
1.3

set

Set the bit specified to the specified value.

fun set(index: Int, value: Boolean = true)

Sets the bits with indices between from (inclusive) and to (exclusive) to the specified value.

fun set(from: Int, to: Int, value: Boolean = true)

Sets the bits from the range specified to the specified value.

fun set(range: IntRange, value: Boolean = true)
Native
1.3

toString

Returns a string representation of the object.

fun toString(): String
Native
1.3

xor

Performs a logical xor operation over corresponding bits of this and another BitSets. The result is saved in this BitSet.

fun xor(another: BitSet)