diff options
Diffstat (limited to 'compiler/nimsets.nim')
-rw-r--r-- | compiler/nimsets.nim | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/nimsets.nim b/compiler/nimsets.nim index 93bccae24..f874ccdca 100644 --- a/compiler/nimsets.nim +++ b/compiler/nimsets.nim @@ -156,6 +156,12 @@ proc equalSets(a, b: PNode): bool = toBitSet(b, y) result = bitSetEquals(x, y) +proc complement*(a: PNode): PNode = + var x: TBitSet + toBitSet(a, x) + for i in countup(0, high(x)): x[i] = not x[i] + result = toTreeSet(x, a.typ, a.info) + proc cardSet(s: PNode): BiggestInt = # here we can do better than converting it into a compact set # we just count the elements directly |