Skip to content

MutableBitSet32

MutableSet implementation that can store values in range 0..31.

To create an instance of this class, use one of the constructors, or the utility functions MutableBitSet32.of, MutableBitSet32.full and MutableBitSet32.empty.

Instances of this class have the following particularities:

  • Operations on a single element execute in O(1).

  • Memory usage is O(1): exactly 32 bits when unboxed.

Instances of this class are not thread-safe.

See also

Constructors

MutableBitSet32

constructor()

Creates an empty MutableBitSet32.

constructor(elements: Iterable<Int>)

Creates a MutableBitSet32 that contains the specified elements.

Types

Companion

object Companion

Properties

size

open override val size: Int

Functions

add

open override fun add(element: Int): Boolean

addAll

open override fun addAll(elements: Collection<Int>): Boolean

clear

open override fun clear()

contains

open operator override fun contains(element: Int): Boolean

containsAll

open override fun containsAll(elements: Collection<Int>): Boolean

equals

open operator override fun equals(other: Any?): Boolean

hashCode

open override fun hashCode(): Int

isEmpty

open override fun isEmpty(): Boolean

iterator

open operator override fun iterator(): MutableIterator<Int>

remove

open override fun remove(element: Int): Boolean

removeAll

open override fun removeAll(elements: Collection<Int>): Boolean

retainAll

open override fun retainAll(elements: Collection<Int>): Boolean

toEnumSet

inline fun <E : Enum<E>> Set<E>.toEnumSet(): Set<E>

Copies a regular Set into a set optimized for enumerations.

Depending on the enumeration size, different implementations may be returned.

Example

enum class Foo {
    A,
    B,
    C,
}

val foo = setOf(Foo.A, Foo.B).toEnumSet()

toMutableEnumSet

inline fun <E : Enum<E>> Set<E>.toMutableEnumSet(): MutableSet<E>

Copies a regular Set into a mutable set optimized for enumerations.

Depending on the enumeration size, different implementations may be returned.

Example

enum class Foo {
    A,
    B,
    C,
}

val foo = setOf(Foo.A, Foo.B).toMutableEnumSet()

toMutableSet

toSet

fun toSet(): BitSet32

toString

open override fun toString(): String