diff options
-rw-r--r-- | lib/pure/collections/tables.nim | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/pure/collections/tables.nim b/lib/pure/collections/tables.nim index 3cb4c27f0..a32abdb0f 100644 --- a/lib/pure/collections/tables.nim +++ b/lib/pure/collections/tables.nim @@ -985,16 +985,19 @@ proc sort*[A](t: CountTableRef[A]) = t[].sort proc merge*[A](s: var CountTable[A], t: CountTable[A]) = + ## merges the second table into the first one for key, value in t: s.inc(key, value) proc merge*[A](s, t: CountTable[A]): CountTable[A] = + ## merges the two tables into a new one result = initCountTable[A](nextPowerOfTwo(max(s.len, t.len))) for table in @[s, t]: for key, value in table: result.inc(key, value) proc merge*[A](s, t: CountTableRef[A]) = + ## merges the second table into the first one s[].merge(t[]) when isMainModule: |