doc comments for merge
This commit is contained in:
parent
73655e3dd6
commit
6dfb13b2b8
1 changed files with 3 additions and 0 deletions
|
|
@ -985,16 +985,19 @@ proc sort*[A](t: CountTableRef[A]) =
|
||||||
t[].sort
|
t[].sort
|
||||||
|
|
||||||
proc merge*[A](s: var CountTable[A], t: CountTable[A]) =
|
proc merge*[A](s: var CountTable[A], t: CountTable[A]) =
|
||||||
|
## merges the second table into the first one
|
||||||
for key, value in t:
|
for key, value in t:
|
||||||
s.inc(key, value)
|
s.inc(key, value)
|
||||||
|
|
||||||
proc merge*[A](s, t: CountTable[A]): CountTable[A] =
|
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)))
|
result = initCountTable[A](nextPowerOfTwo(max(s.len, t.len)))
|
||||||
for table in @[s, t]:
|
for table in @[s, t]:
|
||||||
for key, value in table:
|
for key, value in table:
|
||||||
result.inc(key, value)
|
result.inc(key, value)
|
||||||
|
|
||||||
proc merge*[A](s, t: CountTableRef[A]) =
|
proc merge*[A](s, t: CountTableRef[A]) =
|
||||||
|
## merges the second table into the first one
|
||||||
s[].merge(t[])
|
s[].merge(t[])
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue