The sets module implements an efficient hash set and ordered hash set.
Note: The data types declared here have value semantics: This means that = performs a copy of the set.
Types
TSet* {.final, myShallow.}[A] = object data: TKeyValuePairSeq[A] counter: int
- a generic hash set
TOrderedSet* {.final, myShallow.}[A] = object data: TOrderedKeyValuePairSeq[A] counter, first, last: int
- set that remembers insertion order
Procs
proc len*[A](s: TSet[A]): int
- returns the number of keys in s.
proc card*[A](s: TSet[A]): int
- alias for len.
proc contains*[A](s: TSet[A]; key: A): bool
- returns true iff key is in s.
proc incl*[A](s: var TSet[A]; key: A)
- includes an element key in s.
proc excl*[A](s: var TSet[A]; key: A)
- excludes key from the set s.
proc containsOrIncl*[A](s: var TSet[A]; key: A): bool
- returns true if s contains key, otherwise key is included in s and false is returned.
proc initSet*[A](initialSize = 64): TSet[A]
- creates a new hash set that is empty. initialSize needs to be a power of two.
proc toSet*[A](keys: openarray[A]): TSet[A]
- creates a new hash set that contains the given keys.
proc `$`*[A](s: TSet[A]): string
- The $ operator for hash sets.
proc len*[A](s: TOrderedSet[A]): int {.inline.}
- returns the number of keys in s.
proc card*[A](s: TOrderedSet[A]): int {.inline.}
- alias for len.
proc contains*[A](s: TOrderedSet[A]; key: A): bool
- returns true iff key is in s.
proc incl*[A](s: var TOrderedSet[A]; key: A)
- includes an element key in s.
proc containsOrIncl*[A](s: var TOrderedSet[A]; key: A): bool
- returns true if s contains key, otherwise key is included in s and false is returned.
proc initOrderedSet*[A](initialSize = 64): TOrderedSet[A]
- creates a new ordered hash set that is empty. initialSize needs to be a power of two.
proc toOrderedSet*[A](keys: openarray[A]): TOrderedSet[A]
- creates a new ordered hash set that contains the given keys.
proc `$`*[A](s: TOrderedSet[A]): string
- The $ operator for ordered hash sets.
Iterators
iterator items*[A](s: TSet[A]): A
- iterates over any key in the table t.
iterator items*[A](s: TOrderedSet[A]): A
- iterates over any key in the set s in insertion order.