diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2026-01-26 15:11:07 +0000 |
|---|---|---|
| committer | gingerBill <gingerBill@users.noreply.github.com> | 2026-01-26 15:11:07 +0000 |
| commit | 2859bc08534d00fe8b8b30b55a08a795221d1620 (patch) | |
| tree | 241a188b0faf2c9ad7786e97e0b04a5dfd9b1d6b /core/container | |
| parent | 9f206ba6d5fca31130a43e2ed167b6f898bf3a85 (diff) | |
Update doc.odin
Diffstat (limited to 'core/container')
| -rw-r--r-- | core/container/handle_map/doc.odin | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/core/container/handle_map/doc.odin b/core/container/handle_map/doc.odin index e6ef0b344..c1949ffdd 100644 --- a/core/container/handle_map/doc.odin +++ b/core/container/handle_map/doc.odin @@ -11,22 +11,46 @@ Example: pos: [2]f32, } - entities: hm.Handle_Map(1024, Entity, Handle) + { // static map + entities: hm.Static_Handle_Map(1024, Entity, Handle) - h1 := hm.add(&entities, Entity{pos = {1, 4}}) - h2 := hm.add(&entities, Entity{pos = {9, 16}}) + h1 := hm.add(&entities, Entity{pos = {1, 4}}) + h2 := hm.add(&entities, Entity{pos = {9, 16}}) - if e, ok := hm.get(&entities, h2); ok { - e.pos.x += 32 + if e, ok := hm.get(&entities, h2); ok { + e.pos.x += 32 + } + + hm.remove(&entities, h1) + + h3 := hm.add(&entities, Entity{pos = {6, 7}}) + + it := hm.iterator_make(&entities) + for e, h in hm.iterate(&it) { + e.pos += {1, 2} + } } - hm.remove(&entities, h1) + { // dynamic map + entities: hm.Dynamic_Handle_Map(Entity, Handle) + hm.dynamic_init(&entities, context.allocator) + defer hm.dynamic_destroy(&entities) + + h1 := hm.add(&entities, Entity{pos = {1, 4}}) + h2 := hm.add(&entities, Entity{pos = {9, 16}}) + + if e, ok := hm.get(&entities, h2); ok { + e.pos.x += 32 + } + + hm.remove(&entities, h1) - h3 := hm.add(&entities, Entity{pos = {6, 7}}) + h3 := hm.add(&entities, Entity{pos = {6, 7}}) - it := hm.iterator_make(&entities) - for e, h in hm.iterate(&it) { - e.pos += {1, 2} + it := hm.iterator_make(&entities) + for e, h in hm.iterate(&it) { + e.pos += {1, 2} + } } */ package container_handle_map
\ No newline at end of file |