Set module
This module contains two implementations for collections of unique values. Set stores the values in order, whereas HashSet is unordered but has faster insertion and lookup. The Dict module may also be useful.
Data types
- Set::HashSet<a> - Collection of unique values.
- Set::Set<a> - Ordered collection of unique values.
Functions
- Void add(var HashSet<a> set,a key) - Add an element into a HashSet.
- Void add(var Set<a> set,a val) - Add an element into a Set.
- [a] array(HashSet<a> set) - Return all elements of a HashSet
- [a] array(Set<a> set) - Return all elements of a Set
- Void delete(HashSet<a> set,a key) - Remove an element from a HashSet.
- Void delete(var Set<a> set,a val) - Remove an element from a Set.
- Bool elem(a val,HashSet<a> set) - Check for an element in a HashSet.
- Bool elem(a val,Set<a> set) - Check for an element in a Set.
- Bool empty(HashSet<a> set) - Check whether a HashSet is empty
- Bool empty(Set<a> set) - Check whether a Set is empty
- HashSet<a> newHashSet(Int buckets=157,Int(a) hashfn=hash) - Create a new empty HashSet.
- Set<a> newSet(Int(a, a) cmp=compare) - Create a new empty set.
- Void traverse(Bool(a, Int) block,HashSet<a> set) - Iteration over HashSets
- Void traverse(Bool(a, Int) block,Set<a> set) - Iteration over Sets