IntHashSet

class IntHashSet @JvmOverloads constructor(expectedElements: Int, loadFactor: Double = DEFAULT_LOAD_FACTOR.toDouble()) : Iterable<IntCursor?> , Accountable, Cloneable<IntHashSet>

A hash set of ints, implemented using open addressing with linear probing for collision resolution.

Mostly forked and trimmed from com.carrotsearch.hppc.IntHashSet

github: https://github.com/carrotsearch/hppc release 0.10.0

Constructors

Link copied to clipboard
constructor(expectedElements: Int, loadFactor: Double = DEFAULT_LOAD_FACTOR.toDouble())
constructor()

New instance with sane defaults.

constructor(set: IntHashSet)

New instance copying elements from another set.

constructor(collection: MutableCollection<Int>)

New instance copying elements from another collection.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Returns nested resources of this class. The result should be a point-in-time snapshot (to avoid race conditions).

Link copied to clipboard
Link copied to clipboard

The hash array holding keys.

Functions

Link copied to clipboard
fun add(key: Int): Boolean
Link copied to clipboard
fun addAll(iterable: Iterable<out IntCursor>): Int

Adds all elements from the given iterable to this set.

fun addAll(collection: MutableCollection<Int>): Int

fun addAll(set: IntHashSet): Int

Adds all elements from the given set to this set.

fun addAll(vararg elements: Int): Int

Adds all elements from the given list (vararg) to this set.

Link copied to clipboard
fun clear()
Link copied to clipboard
open override fun clone(): IntHashSet
Link copied to clipboard
fun contains(key: Int): Boolean
Link copied to clipboard
fun ensureCapacity(expectedElements: Int)

Ensure this container can hold at least the given number of elements without resizing its buffers.

Link copied to clipboard
open operator override fun equals(obj: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun indexExists(index: Int): Boolean
Link copied to clipboard
fun indexGet(index: Int): Int

Returns the exact value of the existing key. This method makes sense for sets of objects which define custom key-equality relationship.

Link copied to clipboard
fun indexInsert(index: Int, key: Int)

Inserts a key for an index that is not present in the set. This method may help in avoiding double recalculation of the key's hash.

Link copied to clipboard
fun indexOf(key: Int): Int

Returns a logical "index" of a given key that can be used to speed up follow-up logic in certain scenarios (conditional logic).

Link copied to clipboard
fun indexRemove(index: Int)

Removes a key at an index previously acquired from .indexOf.

Link copied to clipboard
fun indexReplace(index: Int, equivalentKey: Int): Int

Replaces the existing equivalent key with the given one and returns any previous value stored for that key.

Link copied to clipboard
open operator override fun iterator(): MutableIterator<IntCursor?>
Link copied to clipboard
open override fun ramBytesUsed(): Long

Return the memory usage of this object in bytes. Negative values are illegal.

Link copied to clipboard
fun release()
Link copied to clipboard
fun remove(key: Int): Boolean

An alias for the (preferred) .removeAll.

Link copied to clipboard
fun removeAll(other: IntHashSet): Int

Removes all keys present in a given container.

Link copied to clipboard
fun size(): Int
Link copied to clipboard