HashSet[A: Any #share, H: HashFunction[A] val]

A set, built on top of persistent Map. This is implemented as map of an alias of a type to itself.

class val HashSet[A: Any #share, H: HashFunction[A] val] is
  Comparable[HashSet[A, H] box] ref

Implements


Constructors

create

new val create()
: HashSet[A, H] val^

Returns


_create

new val _create(
  map': HashMap[A, A, H] val)
: HashSet[A, H] val^

Parameters

Returns


Public Functions

size

Return the number of elements in the set.

fun box size()
: USize val

Returns


apply

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

fun box apply(
  value: A)
: A ?

Parameters

  • value: A

Returns

  • A ?

contains

Check whether the set contains the value.

fun box contains(
  value: A)
: Bool val

Parameters

  • value: A

Returns


add

Return a set with the value added.

fun val add(
  value: A)
: HashSet[A, H] val

Parameters

  • value: A

Returns


sub

Return a set with the value removed.

fun val sub(
  value: A)
: HashSet[A, H] val

Parameters

  • value: A

Returns


op_or

Return a set with the elements of both this and that.

fun val op_or(
  that: (HashSet[A, H] val | Iterator[A] ref))
: HashSet[A, H] val

Parameters

Returns


op_and

Return a set with the elements that are in both this and that.

fun val op_and(
  that: (HashSet[A, H] val | Iterator[A] ref))
: HashSet[A, H] val

Parameters

Returns


op_xor

Return a set with elements that are in either this or that, but not both.

fun val op_xor(
  that: (HashSet[A, H] val | Iterator[A] ref))
: HashSet[A, H] val

Parameters

Returns


without

Return a set with the elements of this that are not in that.

fun val without(
  that: (HashSet[A, H] val | Iterator[A] ref))
: HashSet[A, H] val

Parameters

Returns


eq

Return true if this and that contain the same elements.

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

Parameters

Returns


lt

Return true if every element in this is also in that, and this has fewer elements than that.

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

Parameters

Returns


le

Return true if every element in this is also in that.

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

Parameters

Returns


gt

Return true if every element in that is also in this, and this has more elements than that.

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

Parameters

Returns


ge

Return true if every element in that is also in this.

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

Parameters

Returns


values

Return an iterator over the values in the set.

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

Returns


compare

fun box compare(
  that: HashSet[A, H] box)
: (Less val | Equal val | Greater val)

Parameters

Returns


ne

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

Parameters

Returns