Module intsets

The intsets module implements an efficient int set implemented as a sparse bit set. Note: Since Nim currently does not allow the assignment operator to be overloaded, = for int sets performs some rather meaningless shallow copy; use assign to get a deep copy.

Types

BitScalar = int
  Source Edit
IntSet = object
  counter, max: int
  head: PTrunk
  data: TrunkSeq
an efficient set of 'int' implemented as a sparse bit set   Source Edit

Procs

proc contains(s: IntSet; key: int): bool {.
raises: [], tags: []
.}
returns true iff key is in s.   Source Edit
proc incl(s: var IntSet; key: int) {.
raises: [], tags: []
.}
includes an element key in s.   Source Edit
proc excl(s: var IntSet; key: int) {.
raises: [], tags: []
.}
excludes key from the set s.   Source Edit
proc containsOrIncl(s: var IntSet; key: int): bool {.
raises: [], tags: []
.}
returns true if s contains key, otherwise key is included in s and false is returned.   Source Edit
proc initIntSet(): IntSet {.
raises: [], tags: []
.}
creates a new int set that is empty.   Source Edit
proc clear(result: var IntSet) {.
raises: [], tags: []
.}
  Source Edit
proc isNil(x: IntSet): bool {.
inline, raises: [], tags: []
.}
  Source Edit
proc assign(dest: var IntSet; src: IntSet) {.
raises: [], tags: []
.}
copies src to dest. dest does not need to be initialized by initIntSet.   Source Edit
proc `$`(s: IntSet): string {.
raises: [], tags: []
.}
The $ operator for int sets.   Source Edit
proc empty(s: IntSet): bool {.
inline, deprecated, raises: [], tags: []
.}
returns true if s is empty. This is safe to call even before the set has been initialized with initIntSet. Note this never worked reliably and so is deprecated.   Source Edit

Iterators

iterator items(s: IntSet): int {.
inline, raises: [], tags: []
.}
iterates over any included element of s.   Source Edit