AWORHashSet[A: Equatable[A] val, H: HashFunction[A] val]¶
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¶
- Comparable[AWORHashSet[A, H] ref] ref
- Causal[AWORHashSet[A, H] ref] ref
Constructors¶
create¶
Instantiate under the given unique replica id.
Parameters¶
- id: ID
Returns¶
- AWORHashSet[A, H] ref^
Public Functions¶
is_empty¶
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.
Returns¶
- Bool val
result¶
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.
Returns¶
- HashSet[A, H] ref
size¶
Return the number of items in the set.
Returns¶
- USize val
contains¶
Check whether the set contains the given value.
Parameters¶
- value': A
Returns¶
- Bool val
set[optional D: AWORHashSet[A, H] ref]¶
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]¶
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]¶
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]¶
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¶
Returns¶
- D^
converge¶
Converge from the given AWORSet into this one. Returns true if the convergence added new information to the data structure.
Parameters¶
- that: AWORHashSet[A, H] box
Returns¶
- Bool val
string¶
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.
Returns¶
- String iso^
eq¶
Parameters¶
- that: AWORHashSet[A, H] box
Returns¶
- Bool val
ne¶
Parameters¶
- that: AWORHashSet[A, H] box
Returns¶
- Bool val
lt¶
Parameters¶
- that: AWORHashSet[A, H] box
Returns¶
- Bool val
le¶
Parameters¶
- that: AWORHashSet[A, H] box
Returns¶
- Bool val
gt¶
Parameters¶
- that: AWORHashSet[A, H] box
Returns¶
- Bool val
ge¶
Parameters¶
- that: AWORHashSet[A, H] box
Returns¶
- Bool val
values¶
Returns¶
- Iterator[A] ref^
from_tokens¶
Deserialize an instance of this data structure from a stream of tokens.
Parameters¶
- that: TokensIterator ref
Returns¶
- None val ?
each_token¶
Serialize the data structure, capturing each token into the given Tokens.
Parameters¶
- tokens: Tokens ref
Returns¶
- None val
compare¶
Parameters¶
- that: AWORHashSet[A, H] box