Btree doesn't have to be a 'ref object'
This commit is contained in:
parent
bd67d7226a
commit
e300692c75
1 changed files with 2 additions and 2 deletions
|
|
@ -16,7 +16,7 @@ type
|
||||||
vals: array[M, Val]
|
vals: array[M, Val]
|
||||||
of true:
|
of true:
|
||||||
links: array[M, Node]
|
links: array[M, Node]
|
||||||
BTree = ref object
|
BTree = object
|
||||||
root: Node
|
root: Node
|
||||||
height: int ## height
|
height: int ## height
|
||||||
n: int ## number of key-value pairs
|
n: int ## number of key-value pairs
|
||||||
|
|
@ -87,7 +87,7 @@ proc insert(h: Node, key: Key, val: Val, ht: int): Node =
|
||||||
inc h.m
|
inc h.m
|
||||||
return if h.m < M: nil else: split(h)
|
return if h.m < M: nil else: split(h)
|
||||||
|
|
||||||
proc put(b: BTree; key: Key; val: Val) =
|
proc put(b: var BTree; key: Key; val: Val) =
|
||||||
let u = insert(b.root, key, val, b.height)
|
let u = insert(b.root, key, val, b.height)
|
||||||
inc b.n
|
inc b.n
|
||||||
if u == nil: return
|
if u == nil: return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue