OrderedTable does not work with non-sequential keys. tested on nim-0.17
var t = initOrderedTable[int,string]()
for i in countUp(1,1000):
var x = random(1000)
t.add(x,"meh")
Traceback (most recent call last)
a10.nim(8) a10
tableimpl.nim(82) add
tables.nim(596) enlarge
tables.nim rawInsert
system.nim(2656) sysFatal
Error: unhandled exception: index out of bounds [IndexError]
As discussed with @Araq I will try to reimplement OrderedTable with a more optimized approach
references for hashmap algorithm, although it will likely end up quite different as Nim is not Python.
https://morepypy.blogspot.fr/2015/01/faster-more-memory-efficient-and-more.html
https://github.com/python/cpython/blob/master/Objects/dictobject.c
Awesome @Parashurama
This has been fixed.
Most helpful comment
As discussed with @Araq I will try to reimplement OrderedTable with a more optimized approach
references for hashmap algorithm, although it will likely end up quite different as Nim is not Python.
https://morepypy.blogspot.fr/2015/01/faster-more-memory-efficient-and-more.html
https://github.com/python/cpython/blob/master/Objects/dictobject.c