#include #include #include vecs_entity_map_s vecs_create_lookup_map() { vecs_entity_map_s map; map.num_entries = 0; map.entries_capacity = 8192; map.entries = malloc(map.entries_capacity * sizeof(vx_uuid_entry_s)); return map; } void vecs_delete_lookup_map(vecs_entity_map_s *map) { free(map->entries); } void * vecs_lookup_entity(vecs_entity_map_s *map, vx_uuid_d uuid) { uint32_t entry_index = 0; while(entry_index < map->num_entries) { vecs_shadow_s *shadow = map->entries[entry_index].shadow; if(shadow->identifier == uuid) { return shadow; } ++entry_index; } return NULL; } void vecs_register_entity(vecs_entity_map_s *map, void *shadow_ptr) { vecs_entity_entry_s *entry = &map->entries[map->num_entries]; entry->shadow = shadow_ptr; ++map->num_entries; } void vecs_unregister_entity(vecs_entity_map_s *map, void *shadow_ptr) { vecs_shadow_s *shadow = shadow_ptr; uint32_t entry_index = 0; while(entry_index < map->num_entries) { vecs_shadow_s *entry = map->entries[entry_index].shadow; if(entry->identifier == shadow->identifier) { map->entries[entry_index] = map->entries[map->num_entries - 1]; break; } ++entry_index; } }