concurrent / org.apache.tuweni.concurrent / AtomicSlotMap

AtomicSlotMap

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.

Constructors

<init>

Create a slot map over the provided domain.

AtomicSlotMap(domain: DiscreteDomain<K>!)

Functions

add

Add a value to the slot map, using the first available slot.

fun add(value: V): K

compute

Find a slot and compute a value for it.

fun compute(fn: Function<in K, out V>!): K

computeAsync

Find a slot and compute a value for it.

fun computeAsync(fn: Function<in K, AsyncResult<out V>!>!): AsyncResult<K>!

entries

fun entries(): Stream<MutableEntry<K, V>!>!

get

Get the value in a slot.

fun get(slot: K): V?

positiveIntegerSlots

Create a slot map over the range of integers > 0.

static fun <V : Any!> positiveIntegerSlots(): AtomicSlotMap<Int!, V>!

put

Put a value into a specific slot.

fun put(slot: K, value: V): V?

remove

Remove a value from a slot, making the slot available again.

fun remove(slot: K): V?

size

fun size(): Int

values

fun values(): Stream<V>!