Set
Set: Set, take, insert, remove, clear, reserve, sum, all, any, none, contains, size, empty, iterator
SetIterator: SetIterator, hasValue, value, increment, sum
struct Set<Key: Hashable>
A set of unique values.
Set
Set()Initializes an empty set
take
Set<Key> take()Moves the set out, leaving an empty set in its place.
insert
void insert(Key key)Inserts an element into the set. If the element exists already, nothing is done.
remove
bool remove(Key& key)Removes an element from the set, returning true if it was there.
clear
void clear()Removes all elements from the set.
reserve
void reserve(int minimumCapacity)Ensures that the bucket count is at least the given number.
sum
Key sum()Returns the sum of the elements, or zero if there are none.
all
bool all<Pred: bool(Key&)>(Pred predicate)Returns true if all elements satisfy the predicate.
bool all<T: Copyable, Pred: bool(T)>(Pred predicate)Returns true if all elements satisfy the predicate.
any
bool any<Pred: bool(Key&)>(Pred predicate)Returns true if any element satisfies the predicate.
bool any<T: Copyable, Pred: bool(T)>(Pred predicate)Returns true if any element satisfies the predicate.
none
bool none<Pred: bool(Key&)>(Pred predicate)Returns true if no element satisfies the predicate.
bool none<T: Copyable, Pred: bool(T)>(Pred predicate)Returns true if no element satisfies the predicate.
contains
bool contains(Key& key)Checks if e is part of the set.
size
int size()Returns the number of elements.
empty
bool empty()Returns true if the set has no elements.
iterator
SetIterator<Key> iterator()Returns an iterator over the elements.
struct SetIterator<Element>: Iterator<Element&>
Iterates over the elements of a set.
SetIterator
SetIterator(Set<Element>& set)Initializes an iterator over the given set.
hasValue
bool hasValue()Returns true if there are more elements.
value
Element& value()Returns the current element.
increment
void increment()Advances to the next element.
sum
Element sum()Returns the sum of the remaining elements, or zero if there are none.