From f0dd38b43162dedbb22d8a64240eb8079c23ce11 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 22 Sep 2011 12:21:24 +0200 Subject: [PATCH] Issue #28: replaced the nested map structure in the CellList --- components/esm_store/reclists.hpp | 38 +++++++------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/components/esm_store/reclists.hpp b/components/esm_store/reclists.hpp index 008bdce0a..7d3afbb96 100644 --- a/components/esm_store/reclists.hpp +++ b/components/esm_store/reclists.hpp @@ -287,8 +287,7 @@ namespace ESMS IntCells intCells; // List of exterior cells. Indexed as extCells[gridX][gridY]. - typedef std::map ExtCellsCol; - typedef std::map ExtCells; + typedef std::map, ESM::Cell*> ExtCells; ExtCells extCells; virtual void listIdentifier (std::vector& identifier) const @@ -303,13 +302,7 @@ namespace ESMS delete it->second; for (ExtCells::iterator it = extCells.begin(); it!=extCells.end(); ++it) - { - ExtCellsCol& col = it->second; - for (ExtCellsCol::iterator it = col.begin(); it!=col.end(); ++it) - { delete it->second; - } - } } @@ -325,17 +318,12 @@ namespace ESMS const ESM::Cell *searchExt (int x, int y) const { - ExtCells::const_iterator it = extCells.find (x); + ExtCells::const_iterator it = extCells.find (std::make_pair (x, y)); if (it==extCells.end()) return 0; - ExtCellsCol::const_iterator it2 = it->second.find (y); - - if (it2 == it->second.end()) - return 0; - - return it2->second; + return it->second; } const ESM::Cell *findExt (int x, int y) const @@ -351,12 +339,8 @@ namespace ESMS { for (ExtCells::const_iterator iter = extCells.begin(); iter!=extCells.end(); ++iter) { - const ExtCellsCol& column = iter->second; - for (ExtCellsCol::const_iterator iter = column.begin(); iter!=column.end(); ++iter) - { - if ( toLower(iter->second->name) == toLower(id)) - return iter->second; - } + if (toLower (iter->second->name) == toLower (id)) + return iter->second; } return 0; @@ -367,14 +351,8 @@ namespace ESMS std::string id2 = toLower (id); for (ExtCells::const_iterator iter = extCells.begin(); iter!=extCells.end(); ++iter) - { - const ExtCellsCol& column = iter->second; - for (ExtCellsCol::const_iterator iter = column.begin(); iter!=column.end(); ++iter) - { - if (toLower (iter->second->region)==id) - return iter->second; - } - } + if (toLower (iter->second->region)==id) + return iter->second; return 0; } @@ -398,7 +376,7 @@ namespace ESMS else { // Store exterior cells by grid position - extCells[cell->data.gridX][cell->data.gridY] = cell; + extCells[std::make_pair (cell->data.gridX, cell->data.gridY)] = cell; } } };