tsigbreak.nim 576 B

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