@@ -11,22 +11,46 @@ Example:
1111 pos: [2]f32,
1212 }
1313
14- entities: hm.Handle_Map(1024, Entity, Handle)
14+ { // static map
15+ entities: hm.Static_Handle_Map(1024, Entity, Handle)
1516
16- h1 := hm.add(&entities, Entity{pos = {1, 4}})
17- h2 := hm.add(&entities, Entity{pos = {9, 16}})
17+ h1 := hm.add(&entities, Entity{pos = {1, 4}})
18+ h2 := hm.add(&entities, Entity{pos = {9, 16}})
1819
19- if e, ok := hm.get(&entities, h2); ok {
20- e.pos.x += 32
20+ if e, ok := hm.get(&entities, h2); ok {
21+ e.pos.x += 32
22+ }
23+
24+ hm.remove(&entities, h1)
25+
26+ h3 := hm.add(&entities, Entity{pos = {6, 7}})
27+
28+ it := hm.iterator_make(&entities)
29+ for e, h in hm.iterate(&it) {
30+ e.pos += {1, 2}
31+ }
2132 }
2233
23- hm.remove(&entities, h1)
34+ { // dynamic map
35+ entities: hm.Dynamic_Handle_Map(Entity, Handle)
36+ hm.dynamic_init(&entities, context.allocator)
37+ defer hm.dynamic_destroy(&entities)
38+
39+ h1 := hm.add(&entities, Entity{pos = {1, 4}})
40+ h2 := hm.add(&entities, Entity{pos = {9, 16}})
41+
42+ if e, ok := hm.get(&entities, h2); ok {
43+ e.pos.x += 32
44+ }
45+
46+ hm.remove(&entities, h1)
2447
25- h3 := hm.add(&entities, Entity{pos = {6, 7}})
48+ h3 := hm.add(&entities, Entity{pos = {6, 7}})
2649
27- it := hm.iterator_make(&entities)
28- for e, h in hm.iterate(&it) {
29- e.pos += {1, 2}
50+ it := hm.iterator_make(&entities)
51+ for e, h in hm.iterate(&it) {
52+ e.pos += {1, 2}
53+ }
3054 }
3155*/
3256package container_handle_map
0 commit comments