add incl/excl for sets accepting accepting other sets
This commit is contained in:
parent
046d829e5d
commit
88873f7965
1 changed files with 8 additions and 0 deletions
|
|
@ -422,10 +422,18 @@ proc incl*[T](x: var set[T], y: T) {.magic: "Incl", noSideEffect.}
|
||||||
## includes element ``y`` to the set ``x``. This is the same as
|
## includes element ``y`` to the set ``x``. This is the same as
|
||||||
## ``x = x + {y}``, but it might be more efficient.
|
## ``x = x + {y}``, but it might be more efficient.
|
||||||
|
|
||||||
|
template incl*[T](s: var set[T], flags: set[T]) =
|
||||||
|
## includes the set of flags to the set ``x``.
|
||||||
|
s = s + flags
|
||||||
|
|
||||||
proc excl*[T](x: var set[T], y: T) {.magic: "Excl", noSideEffect.}
|
proc excl*[T](x: var set[T], y: T) {.magic: "Excl", noSideEffect.}
|
||||||
## excludes element ``y`` to the set ``x``. This is the same as
|
## excludes element ``y`` to the set ``x``. This is the same as
|
||||||
## ``x = x - {y}``, but it might be more efficient.
|
## ``x = x - {y}``, but it might be more efficient.
|
||||||
|
|
||||||
|
template excl*[T](s: var set[T], flags: set[T]) =
|
||||||
|
## excludes the set of flags to ``x``.
|
||||||
|
s = s - flags
|
||||||
|
|
||||||
proc card*[T](x: set[T]): int {.magic: "Card", noSideEffect.}
|
proc card*[T](x: set[T]): int {.magic: "Card", noSideEffect.}
|
||||||
## returns the cardinality of the set ``x``, i.e. the number of elements
|
## returns the cardinality of the set ``x``, i.e. the number of elements
|
||||||
## in the set.
|
## in the set.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue