#include namespace psemek::ecs { bool entity_container::alive(entity_handle const & entity) const { return entity_list_.get_entities()[entity.id].epoch == entity.epoch; } void entity_container::destroy(entity_handle const & entity) { // Swap with the last row in that table auto entities = entity_list_.get_entities(); auto & data = entities[entity.id]; auto table_entity_handles = data.table->get_entity_handles(); data.table->swap_rows(data.row, table_entity_handles.size() - 1); data.table->pop_row(); auto swap_handle = table_entity_handles[data.row]; auto & swap_data = entities[swap_handle.id]; swap_data.row = data.row; entity_list_.destroy(entity.id); } entity_accessor entity_container::get(entity_handle const & entity) { auto const & data = entity_list_.get_entities()[entity.id]; return {data.table, data.row}; } }