new test cases
worked on all walkers new helper methods new distributions some bugfixes
This commit is contained in:
22
grid/Grid.h
22
grid/Grid.h
@@ -235,6 +235,11 @@ public:
|
||||
remove(nodes[idx]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* mark the given node for deletion
|
||||
* see: cleanup()
|
||||
*/
|
||||
void remove(T& node) {
|
||||
|
||||
// disconnect from all neighbors
|
||||
@@ -250,8 +255,11 @@ public:
|
||||
|
||||
}
|
||||
|
||||
/** remove all nodes marked for deletion */
|
||||
void cleanup() {
|
||||
|
||||
debugMemoryUsage();
|
||||
|
||||
Log::add(name, "running grid cleanup", false);
|
||||
Log::tick();
|
||||
|
||||
@@ -293,6 +301,8 @@ public:
|
||||
|
||||
rebuildHashes();
|
||||
|
||||
debugMemoryUsage();
|
||||
|
||||
}
|
||||
|
||||
/** rebuild the UID-hash-list */
|
||||
@@ -310,6 +320,18 @@ public:
|
||||
|
||||
}
|
||||
|
||||
/** debug-print the grid's current memory usage */
|
||||
void debugMemoryUsage() {
|
||||
const uint32_t bytes = nodes.size() * sizeof(T);
|
||||
const uint32_t numNodes = nodes.size();
|
||||
uint32_t numNeighbors = 0;
|
||||
//uint32_t numNeighborsUnused = 0;
|
||||
for (T& n : nodes) {
|
||||
numNeighbors += n._numNeighbors;
|
||||
}
|
||||
Log::add(name, "memory: " + std::to_string(bytes/1024.0f/1024.0f) + " MB in " + std::to_string(numNodes) + " nodes");
|
||||
}
|
||||
|
||||
// /**
|
||||
// * remove all nodes, marked for deletion.
|
||||
// * BEWARE: this will invalidate all indices used externally!
|
||||
|
||||
Reference in New Issue
Block a user