BitSet

class BitSet(size: Int = ELEMENT_SIZE)(source)

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

Since Kotlin

1.3

Parameters

size

the size of one element in the array used to store bits.

Constructors

Link copied to clipboard
constructor(length: Int, initializer: (Int) -> Boolean)

Creates a bit set of given length filling elements using initializer

constructor(size: Int = ELEMENT_SIZE)

creates an empty bit set with the specified size

Types

Link copied to clipboard
object Companion
Since Kotlin 1.3

Properties

Link copied to clipboard

True if this BitSet contains no bits set to true.

Since Kotlin 1.3
Link copied to clipboard

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

Since Kotlin 1.3
Link copied to clipboard
var size: Int

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

Since Kotlin 1.3

Functions

Link copied to clipboard
fun and(another: BitSet)

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

Since Kotlin 1.3
Link copied to clipboard
fun andNot(another: BitSet)

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

Since Kotlin 1.3
Link copied to clipboard
fun clear()

Sets all bits in the BitSet to false.

Since Kotlin 1.3
fun clear(index: Int)
fun clear(range: IntRange)

Clears the bit specified

Since Kotlin 1.3
fun clear(from: Int, to: Int)

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

Since Kotlin 1.3
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Since Kotlin 1.3
Link copied to clipboard
fun flip(index: Int)

Reverses the bit specified.

Since Kotlin 1.3
fun flip(range: IntRange)

Reverses the bits from the range specified.

Since Kotlin 1.3
fun flip(from: Int, to: Int)

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

Since Kotlin 1.3
Link copied to clipboard
operator fun get(index: Int): Boolean

Returns a value of a bit with the index specified.

Since Kotlin 1.3
Link copied to clipboard
open override fun hashCode(): Int
Since Kotlin 1.3
Link copied to clipboard
fun intersects(another: BitSet): Boolean

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

Since Kotlin 1.3
Link copied to clipboard
fun nextClearBit(startIndex: Int = 0): Int

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.

Since Kotlin 1.3
Link copied to clipboard
fun nextSetBit(startIndex: Int = 0): Int

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

Since Kotlin 1.3
Link copied to clipboard
fun or(another: BitSet)

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

Since Kotlin 1.3
Link copied to clipboard
fun previousBit(startIndex: Int, lookFor: Boolean): Int

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

Since Kotlin 1.3
Link copied to clipboard
fun previousClearBit(startIndex: Int): Int

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.

Since Kotlin 1.3
Link copied to clipboard
fun previousSetBit(startIndex: Int): Int

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.

Since Kotlin 1.3
Link copied to clipboard
fun set(index: Int, value: Boolean = true)

Set the bit specified to the specified value.

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

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

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

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

Since Kotlin 1.3
Link copied to clipboard
open override fun toString(): String
Since Kotlin 1.3
Link copied to clipboard
fun xor(another: BitSet)

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

Since Kotlin 1.3