diff --git a/lib/pure/collections/critbits.nim b/lib/pure/collections/critbits.nim index 424bcdcca7..09b20fd450 100644 --- a/lib/pure/collections/critbits.nim +++ b/lib/pure/collections/critbits.nim @@ -123,6 +123,14 @@ proc containsOrIncl*(c: var CritBitTree[void], key: string): bool = var n = rawInsert(c, key) result = c.count == oldCount +proc inc*(c: var CritBitTree[int]; key: string) = + ## counts the 'key'. + let oldCount = c.count + var n = rawInsert(c, key) + if c.count == oldCount: + # not a new key: + inc n.val + proc incl*(c: var CritBitTree[void], key: string) = ## includes `key` in `c`. discard rawInsert(c, key)