Skip to content

BitSet32

@JvmInline
value class BitSet32 : Set<Int> 

Immutable Set implementation that can store values in range 0..31.

To create an instance of this class, see BitSet32.of, BitSet32.full and BitSet32.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.

See also

Types

Companion

object Companion

Properties

size

open override val size: Int

Functions

contains

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

containsAll

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

isEmpty

open override fun isEmpty(): Boolean

iterator

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

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