updated test cases
This commit is contained in:
parent
e079db95f8
commit
bbb5ce38c7
2 changed files with 5 additions and 5 deletions
|
|
@ -19,11 +19,11 @@ proc mustRehash(length, counter: int): bool {.inline.} =
|
||||||
assert(length > counter)
|
assert(length > counter)
|
||||||
result = (length * 2 < counter * 3) or (length - counter < 4)
|
result = (length * 2 < counter * 3) or (length - counter < 4)
|
||||||
|
|
||||||
proc nextTry(h, maxHash: THash): THash {.inline.} =
|
proc nextTry(h, maxHash: Hash): Hash {.inline.} =
|
||||||
result = ((5 * h) + 1) and maxHash
|
result = ((5 * h) + 1) and maxHash
|
||||||
|
|
||||||
template rawGetImpl() {.dirty.} =
|
template rawGetImpl() {.dirty.} =
|
||||||
var h: THash = hash(key) and high(t.data) # start with real hash value
|
var h: Hash = hash(key) and high(t.data) # start with real hash value
|
||||||
while t.data[h].slot != seEmpty:
|
while t.data[h].slot != seEmpty:
|
||||||
if t.data[h].key == key and t.data[h].slot == seFilled:
|
if t.data[h].key == key and t.data[h].slot == seFilled:
|
||||||
return h
|
return h
|
||||||
|
|
@ -31,7 +31,7 @@ template rawGetImpl() {.dirty.} =
|
||||||
result = -1
|
result = -1
|
||||||
|
|
||||||
template rawInsertImpl() {.dirty.} =
|
template rawInsertImpl() {.dirty.} =
|
||||||
var h: THash = hash(key) and high(data)
|
var h: Hash = hash(key) and high(data)
|
||||||
while data[h].slot == seFilled:
|
while data[h].slot == seFilled:
|
||||||
h = nextTry(h, high(data))
|
h = nextTry(h, high(data))
|
||||||
data[h].key = key
|
data[h].key = key
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@ proc main(param: int) =
|
||||||
# test simple closure within dummy 'main':
|
# test simple closure within dummy 'main':
|
||||||
proc dummy =
|
proc dummy =
|
||||||
proc main2(param: int) =
|
proc main2(param: int) =
|
||||||
var foo = 23
|
var fooB = 23
|
||||||
proc outer(outerParam: string) =
|
proc outer(outerParam: string) =
|
||||||
var outerVar = 88
|
var outerVar = 88
|
||||||
echo outerParam, outerVar
|
echo outerParam, outerVar
|
||||||
proc inner() =
|
proc inner() =
|
||||||
block Test:
|
block Test:
|
||||||
echo foo, " ", param, outerParam, " ", outerVar
|
echo fooB, " ", param, outerParam, " ", outerVar
|
||||||
inner()
|
inner()
|
||||||
outer("foo")
|
outer("foo")
|
||||||
main2(24)
|
main2(24)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue