Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement