Skip to content

AWORHashSet[A: Equatable[A] val, H: HashFunction[A] val]

[Source]

An unordered mutable set that supports removing locally visible elements ("observed remove") using per-replica sequence numbers to track causality.

In the case where an insertion and a deletion for the same element have no causal relationship (they happened concurrently on different replicas), the insertion will override the deletion ("add wins"). For a similar data structure with the opposite bias, see the "remove wins" variant (RWORSet).

This data structure delegates causality tracking to the reusable "dot kernel" abstraction. Because that abstraction provides an eventually-consistent set of replica-associated values, and this data structure uses a commutative strategy for reading out the values, the result is eventually consistent.

All mutator methods accept and return a convergent delta-state.

class ref AWORHashSet[A: Equatable[A] val, H: HashFunction[A] val] is
  Comparable[AWORHashSet[A, H] ref] ref,
  Causal[AWORHashSet[A, H] ref] ref

Implements


Constructors

create

[Source]

Instantiate under the given unique replica id.

new ref create(
  id: ID)
: AWORHashSet[A, H] ref^

Parameters

Returns


Public Functions

is_empty

[Source]

Return true if there are no values ever recorded from any replica. This is true at creation, after calling the clear method, or after a converge that results in all values being cleared.

fun box is_empty()
: Bool val

Returns


result

[Source]

Return the elements of the resulting logical set as a single flat set. Information about specific deletions is discarded, so that the case of a deleted element is indistinct from that of an element never inserted.

fun box result()
: HashSet[A, H] ref

Returns


size

[Source]

Return the number of items in the set.

fun box size()
: USize val

Returns


contains

[Source]

Check whether the set contains the given value.

fun box contains(
  value': A)
: Bool val

Parameters

  • value': A

Returns


set[optional D: AWORHashSet[A, H] ref]

[Source]

Add a value to the set. Accepts and returns a convergent delta-state.

fun ref set[optional D: AWORHashSet[A, H] ref](
  value': A,
  delta': D = recover AWORHashSet[A, H](0) end)
: D^

Parameters

  • value': A
  • delta': D = recover AWORHashSetA, H end

Returns

  • D^

unset[optional D: AWORHashSet[A, H] ref]

[Source]

Remove a value from the set. Accepts and returns a convergent delta-state.

fun ref unset[optional D: AWORHashSet[A, H] ref](
  value': A,
  delta': D = recover AWORHashSet[A, H](0) end)
: D^

Parameters

  • value': A
  • delta': D = recover AWORHashSetA, H end

Returns

  • D^

clear[optional D: AWORHashSet[A, H] ref]

[Source]

Remove all locally visible elements from the set. Accepts and returns a convergent delta-state.

fun ref clear[optional D: AWORHashSet[A, H] ref](
  delta': D = recover AWORHashSet[A, H](0) end)
: D^

Parameters

  • delta': D = recover AWORHashSetA, H end

Returns

  • D^

union[optional D: AWORHashSet[A, H] ref]

[Source]

Add everything in the given iterator to the set. Accepts and returns a convergent delta-state.

fun ref union[optional D: AWORHashSet[A, H] ref](
  that': Iterator[A] ref,
  delta': D = recover AWORHashSet[A, H](0) end)
: D^

Parameters

  • that': Iterator[A] ref
  • delta': D = recover AWORHashSetA, H end

Returns

  • D^

converge

[Source]

Converge from the given AWORSet into this one. Returns true if the convergence added new information to the data structure.

fun ref converge(
  that: AWORHashSet[A, H] box)
: Bool val

Parameters

Returns


string

[Source]

Return a best effort at printing the set. If A is a Stringable, use the string representation of each value; otherwise print them as question marks.

fun box string()
: String iso^

Returns


eq

[Source]

fun box eq(
  that: AWORHashSet[A, H] box)
: Bool val

Parameters

Returns


ne

[Source]

fun box ne(
  that: AWORHashSet[A, H] box)
: Bool val

Parameters

Returns


lt

[Source]

fun box lt(
  that: AWORHashSet[A, H] box)
: Bool val

Parameters

Returns


le

[Source]

fun box le(
  that: AWORHashSet[A, H] box)
: Bool val

Parameters

Returns


gt

[Source]

fun box gt(
  that: AWORHashSet[A, H] box)
: Bool val

Parameters

Returns


ge

[Source]

fun box ge(
  that: AWORHashSet[A, H] box)
: Bool val

Parameters

Returns


values

[Source]

fun box values()
: Iterator[A] ref^

Returns


from_tokens

[Source]

Deserialize an instance of this data structure from a stream of tokens.

fun ref from_tokens(
  that: TokensIterator ref)
: None val ?

Parameters

Returns


each_token

[Source]

Serialize the data structure, capturing each token into the given Tokens.

fun ref each_token(
  tokens: Tokens ref)
: None val

Parameters

Returns


compare

[Source]

fun box compare(
  that: AWORHashSet[A, H] box)
: Compare

Parameters

Returns