From 88873f7965d04cc2bea56f2b957e3b506442c582 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Mon, 30 Dec 2013 14:25:05 +0200 Subject: [PATCH] add incl/excl for sets accepting accepting other sets --- lib/system.nim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/system.nim b/lib/system.nim index 978fae1a6e..241b0bd034 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -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 ## ``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.} ## excludes element ``y`` to the set ``x``. This is the same as ## ``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.} ## returns the cardinality of the set ``x``, i.e. the number of elements ## in the set.