ORMap

@Serializable
class ORMap<K, S : Quilted<S>> : Quilted<ORMap<K, S>>

An observed-remove map: keys K each carry a Quilted value S that merges via its own Quilted.piece. A concurrent put of the same key survives a remove (add-wins on the key), and when both replicas hold the key the values are pieced together.

Built over Causal<DotMap<K, ORMapEntry<S>>>: each entry's tags is the observed-remove handle for the key; the value lives alongside and is merged by its own piece.

Samples

val a = ReplicaId("A")
val b = ReplicaId("B")

val start = ORMap.empty<String, GSet<String>>()
    .put(a, "team", GSet.of("alice"))

val alice = start.remove("team")                          // Alice removes the key
val bob = start.put(b, "team", GSet.of("bob"))            // Bob concurrently adds

val merged = alice.piece(bob)
check("team" in merged.keys)                               // add-wins on the key

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val keys: Set<K>

Currently-present keys.

Functions

Link copied to clipboard
open fun causalDots(): Set<Dot>

The causal Dots this state has delivered — (author, author-seq) per op.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
operator fun get(key: K): S?

The value for key, or null if absent.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun piece(other: ORMap<K, S>): ORMap<K, S>

The causal merge.

Link copied to clipboard
fun put(replica: ReplicaId, key: K, value: S): ORMap<K, S>

Put value under key, minting a fresh add-tag on behalf of replica. If the key already exists locally, the new value is pieced with the existing one (so a put is additive, not destructive, for the value lattice).

Link copied to clipboard
fun remove(key: K): ORMap<K, S>

Remove key: drop its current tags. Context retains them — propagates on merge.

Link copied to clipboard
open override fun toString(): String