tsigbreak.nim 564 B

1234567891011121314151617181920212223242526272829
  1. discard """
  2. cmd: "nim cpp $file"
  3. """
  4. import tables, lists
  5. type
  6. ListTable[K, V] = object
  7. table: Table[K, DoublyLinkedNode[V]]
  8. proc initListTable*[K, V](initialSize = 64): ListTable[K, V] =
  9. result.table = initTable[K, DoublyLinkedNode[V]]()
  10. proc `[]=`*[K, V](t: var ListTable[K, V], key: K, val: V) =
  11. t.table[key].value = val
  12. type
  13. SomeObj = object
  14. OtherObj = object
  15. proc main() =
  16. var someTable = initListTable[int, SomeObj]()
  17. var otherTable = initListTable[int, OtherObj]()
  18. someTable[1] = SomeObj()
  19. otherTable[42] = OtherObj()
  20. main()