Skip to content

GHashSet[A: Any val, H: HashFunction[A] val]

[Source]

An unordered mutable grow-only set. That is, it only allows insertion.

Because the set is unordered and elements can only be added (never deleted), the results are eventually consistent when converged.

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

class ref GHashSet[A: Any val, H: HashFunction[A] val] is
  Comparable[GHashSet[A, H] ref] ref,
  Convergent[GHashSet[A, H] ref] ref,
  Replicated ref

Implements


Constructors

create

[Source]

new ref create()
: GHashSet[A, H] ref^

Returns


Public Functions

is_empty

[Source]

Return true if the data structure contains no information (bottom state).

fun box is_empty()
: Bool val

Returns


size

[Source]

Return the number of items in the set.

fun box size()
: USize val

Returns


apply

[Source]

Return the value if it's in the set, otherwise raise an error.

fun box apply(
  value: val->A)
: val->A ?

Parameters

  • value: val->A

Returns

  • val->A ?

contains

[Source]

Check whether the set contains the given value.

fun box contains(
  value: val->A)
: Bool val

Parameters

  • value: val->A

Returns


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

[Source]

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

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

Parameters

  • value: A
  • delta: D = recover GHashSet[A, H] end

Returns

  • D^

union[optional D: GHashSet[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: GHashSet[A, H] ref](
  that: Iterator[A] ref,
  delta: D = recover GHashSet[A, H] end)
: D^

Parameters

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

Returns

  • D^

converge

[Source]

Converge from the given GSet into this one. For this data type, the convergence is a simple union. Returns true if the convergence added new information to the data structure.

fun ref converge(
  that: GHashSet[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: GHashSet[A, H] box)
: Bool val

Parameters

Returns


ne

[Source]

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

Parameters

Returns


lt

[Source]

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

Parameters

Returns


le

[Source]

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

Parameters

Returns


gt

[Source]

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

Parameters

Returns


ge

[Source]

fun box ge(
  that: GHashSet[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: GHashSet[A, H] box)
: Compare

Parameters

Returns