## SlotMap type Slot*[T] = object slotMap: SlotMap index: int SlotMap*[T] = ref object perChunk: int chunks: seq[pointer] proc newSlotMap*[T](perChunk: int): SlotMap[T] = new(result) result.chunks = @[] result.perChunk = perChunk proc add*[T](slotMap: SlotMap[T], item: T): Slot[T] = Slot[T](slotMap: slotMap, index: 0) #TODO: allocate in chunk, return allocated index ## tests when isMainModule: type Component = object var sm = newSlotMap[Component](128) echo $sm.perChunk var obj = sm.add(Component()) echo $obj.index