HashSet[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
Implements¶
- Comparable[HashSet[A, H] box] ref
Constructors¶
create¶
Defaults to a prealloc of 8.
Parameters¶
- prealloc: USize val = 8
Returns¶
- HashSet[A, H] ref^
Public Functions¶
size¶
The number of items in the set.
Returns¶
- USize val
space¶
The available space in the set.
Returns¶
- USize val
apply¶
Return the value if its in the set, otherwise raise an error.
Parameters¶
- value: box->A!
Returns¶
- this->A ?
contains¶
Checks whether the set contains the value.
Parameters¶
- value: box->A!
Returns¶
- Bool val
clear¶
Remove all elements from the set.
Returns¶
- None val
set¶
Add a value to the set.
Parameters¶
- value: A
Returns¶
- None val
unset¶
Remove a value from the set.
Parameters¶
- value: box->A!
Returns¶
- None val
extract¶
Remove a value from the set and return it. Raises an error if the value wasn't in the set.
Parameters¶
- value: box->A!
Returns¶
- A^ ?
union¶
Add everything in that to the set.
Parameters¶
- that: Iterator[A^] ref
Returns¶
- None val
intersect[optional K: HashFunction[box->A!] val]¶
Remove everything that isn't in that.
Parameters¶
- that: HashSet[box->A!, K] ref
Returns¶
- None val
difference¶
Remove elements in this which are also in that. Add elements in that which are not in this.
Parameters¶
- that: Iterator[A^] ref
Returns¶
- None val
remove¶
Remove everything that is in that.
Parameters¶
- that: Iterator[box->A!] ref
Returns¶
- None val
add[optional K: HashFunction[this->A!] val]¶
Add a value to the set.
Parameters¶
- value: this->A!
Returns¶
- HashSet[this->A!, K] ref^
sub[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[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[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[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[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[optional K: HashFunction[this->A!] val]¶
Create a clone. The element type may be different due to aliasing and viewpoint adaptation.
Returns¶
- HashSet[this->A!, K] ref^
eq¶
Returns true if the sets contain the same elements.
Parameters¶
- that: HashSet[A, H] box
Returns¶
- Bool val
ne¶
Returns false if the sets contain the same elements.
Parameters¶
- that: HashSet[A, H] box
Returns¶
- Bool val
lt¶
Returns true if every element in this is also in that, and this has fewer elements than that.
Parameters¶
- that: HashSet[A, H] box
Returns¶
- Bool val
le¶
Returns true if every element in this is also in that.
Parameters¶
- that: HashSet[A, H] box
Returns¶
- Bool val
gt¶
Returns true if every element in that is also in this, and this has more elements than that.
Parameters¶
- that: HashSet[A, H] box
Returns¶
- Bool val
ge¶
Returns true if every element in that is also in this.
Parameters¶
- that: HashSet[A, H] box
Returns¶
- Bool val
next_index¶
Given an index, return the next index that has a populated value. Raise an error if there is no next populated index.
Parameters¶
- prev: USize val = call
Returns¶
- USize val ?
index¶
Returns the value at a given index. Raise an error if the index is not populated.
Parameters¶
- i: USize val
Returns¶
- this->A ?
values¶
Return an iterator over the values.
Returns¶
compare¶
Parameters¶
- that: HashSet[A, H] box