HashSet [Src] [A: A, H: HashFunction[A!] val]
A set, built on top of a HashMap. This is implemented as map of an alias of a type to itself
class ref HashSet[A: A, H: HashFunction[A!] val] is
Comparable[HashSet[A, H] box] ref
Implements
- Comparable[HashSet[A, H] box] ref
Constructors
create [Src]
Defaults to a prealloc of 8.
new ref create(
prealloc: USize val = seq)
: HashSet[A, H] ref^
Parameters
- prealloc: USize val = seq
Returns
- HashSet[A, H] ref^
Public Functions
size [Src]
The number of items in the set.
fun box size()
: USize val
Returns
- USize val
space [Src]
The available space in the set.
fun box space()
: USize val
Returns
- USize val
apply [Src]
Return the value if its in the set, otherwise raise an error.
fun box apply(
value: box->A!)
: this->A ?
Parameters
- value: box->A!
Returns
- this->A ?
contains [Src]
Checks whether the set contains the value.
fun box contains(
value: box->A!)
: Bool val
Parameters
- value: box->A!
Returns
- Bool val
clear [Src]
Remove all elements from the set.
fun ref clear()
: None val
Returns
- None val
set [Src]
Add a value to the set.
fun ref set(
value: A)
: None val
Parameters
- value: A
Returns
- None val
unset [Src]
Remove a value from the set.
fun ref unset(
value: box->A!)
: None val
Parameters
- value: box->A!
Returns
- None val
extract [Src]
Remove a value from the set and return it. Raises an error if the value wasn't in the set.
fun ref extract(
value: box->A!)
: A^ ?
Parameters
- value: box->A!
Returns
- A^ ?
union [Src]
Add everything in that to the set.
fun ref union(
that: Iterator[A^] ref)
: None val
Parameters
- that: Iterator[A^] ref
Returns
- None val
intersect [Src] [optional K: HashFunction[box->A!] val]
Remove everything that isn't in that.
fun ref intersect[optional K: HashFunction[box->A!] val](
that: HashSet[box->A!, K] ref)
: None val
Parameters
- that: HashSet[box->A!, K] ref
Returns
- None val
difference [Src]
Remove elements in this which are also in that. Add elements in that which are not in this.
fun ref difference(
that: Iterator[A^] ref)
: None val
Parameters
- that: Iterator[A^] ref
Returns
- None val
remove [Src]
Remove everything that is in that.
fun ref remove(
that: Iterator[box->A!] ref)
: None val
Parameters
- that: Iterator[box->A!] ref
Returns
- None val
add [Src] [optional K: HashFunction[this->A!] val]
Add a value to the set.
fun box add[optional K: HashFunction[this->A!] val](
value: this->A!)
: HashSet[this->A!, K] ref^
Parameters
- value: this->A!
Returns
- HashSet[this->A!, K] ref^
sub [Src] [optional K: HashFunction[this->A!] val]
Remove a value from the set.
fun box sub[optional K: HashFunction[this->A!] val](
value: box->this->A!)
: HashSet[this->A!, K] ref^
Parameters
- value: box->this->A!
Returns
- HashSet[this->A!, K] ref^
op_or [Src] [optional K: HashFunction[this->A!] val]
Create a set with the elements of both this and that.
fun box op_or[optional K: HashFunction[this->A!] val](
that: this->HashSet[A, H] ref)
: HashSet[this->A!, K] ref^
Parameters
- that: this->HashSet[A, H] ref
Returns
- HashSet[this->A!, K] ref^
op_and [Src] [optional K: HashFunction[this->A!] val]
Create a set with the elements that are in both this and that.
fun box op_and[optional K: HashFunction[this->A!] val](
that: this->HashSet[A, H] ref)
: HashSet[this->A!, K] ref^
Parameters
- that: this->HashSet[A, H] ref
Returns
- HashSet[this->A!, K] ref^
op_xor [Src] [optional K: HashFunction[this->A!] val]
Create a set with the elements that are in either set but not both.
fun box op_xor[optional K: HashFunction[this->A!] val](
that: this->HashSet[A, H] ref)
: HashSet[this->A!, K] ref^
Parameters
- that: this->HashSet[A, H] ref
Returns
- HashSet[this->A!, K] ref^
without [Src] [optional K: HashFunction[this->A!] val]
Create a set with the elements of this that are not in that.
fun box without[optional K: HashFunction[this->A!] val](
that: this->HashSet[A, H] ref)
: HashSet[this->A!, K] ref^
Parameters
- that: this->HashSet[A, H] ref
Returns
- HashSet[this->A!, K] ref^
clone [Src] [optional K: HashFunction[this->A!] val]
Create a clone. The element type may be different due to aliasing and viewpoint adaptation.
fun box clone[optional K: HashFunction[this->A!] val]()
: HashSet[this->A!, K] ref^
Returns
- HashSet[this->A!, K] ref^
eq [Src]
Returns true if the sets contain the same elements.
fun box eq(
that: HashSet[A, H] box)
: Bool val
Parameters
- that: HashSet[A, H] box
Returns
- Bool val
ne [Src]
Returns false if the sets contain the same elements.
fun box ne(
that: HashSet[A, H] box)
: Bool val
Parameters
- that: HashSet[A, H] box
Returns
- Bool val
lt [Src]
Returns 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
- that: HashSet[A, H] box
Returns
- Bool val
le [Src]
Returns true if every element in this is also in that.
fun box le(
that: HashSet[A, H] box)
: Bool val
Parameters
- that: HashSet[A, H] box
Returns
- Bool val
gt [Src]
Returns 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
- that: HashSet[A, H] box
Returns
- Bool val
ge [Src]
Returns true if every element in that is also in this.
fun box ge(
that: HashSet[A, H] box)
: Bool val
Parameters
- that: HashSet[A, H] box
Returns
- Bool val
next_index [Src]
Given an index, return the next index that has a populated value. Raise an error if there is no next populated index.
fun box next_index(
prev: USize val = seq)
: USize val ?
Parameters
- prev: USize val = seq
Returns
- USize val ?
index [Src]
Returns the value at a given index. Raise an error if the index is not populated.
fun box index(
i: USize val)
: this->A ?
Parameters
- i: USize val
Returns
- this->A ?
values [Src]
Return an iterator over the values.
fun box values()
: SetValues[A, H, this->HashSet[A, H] ref] ref^
Returns
compare [Src]
fun box compare(
that: HashSet[A, H] box)
: (Less val | Equal val | Greater val)
Parameters
- that: HashSet[A, H] box