class AtomicSlotMap<K : Comparable<Any?>, V : Any>
(source)
An atomic map that locates available keys within a DiscreteDomain.
This is an atomic map that will allocate key slots based on availability. It will attempt to keep the range compact by filling slots as they become available.
This implementation should be used with small sets, as addition is an O(N) operation.
- The type of values to store in the map.
AtomicSlotMap(domain: DiscreteDomain<K>)
Create a slot map over the provided domain. |
fun add(value: V): K
Add a value to the slot map, using the first available slot. |
|
fun compute(fn: Function<in K, out V>): K
Find a slot and compute a value for it. |
|
fun computeAsync(fn: Function<in K, AsyncResult<out V>>): AsyncResult<K>
Find a slot and compute a value for it. |
|
fun entries(): Stream<MutableEntry<K, V>> |
|
fun get(slot: K): V?
Get the value in a slot. |
|
static fun <V : Any> positiveIntegerSlots(): AtomicSlotMap<Int, V>
Create a slot map over the range of integers > 0. |
|
fun put(slot: K, value: V): V?
Put a value into a specific slot. |
|
fun remove(slot: K): V?
Remove a value from a slot, making the slot available again. |
|
fun size(): Int |
|
fun values(): Stream<V> |