Change CleanupReturnType to std::vector
This commit is contained in:
parent
506b027655
commit
60bf841c11
2 changed files with 10 additions and 13 deletions
|
@ -21,7 +21,6 @@
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <queue>
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -331,13 +330,13 @@ namespace EC
|
||||||
parameter is undefined as it is not used in that case.
|
parameter is undefined as it is not used in that case.
|
||||||
*/
|
*/
|
||||||
using CleanupReturnType =
|
using CleanupReturnType =
|
||||||
std::queue<std::tuple<bool, std::size_t, std::size_t> >;
|
std::vector<std::tuple<bool, std::size_t, std::size_t> >;
|
||||||
CleanupReturnType cleanup()
|
CleanupReturnType cleanup()
|
||||||
{
|
{
|
||||||
CleanupReturnType changedQueue;
|
CleanupReturnType changedVector;
|
||||||
if(currentSize == 0)
|
if(currentSize == 0)
|
||||||
{
|
{
|
||||||
return changedQueue;
|
return changedVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t rhs = currentSize - 1;
|
std::size_t rhs = currentSize - 1;
|
||||||
|
@ -350,9 +349,9 @@ namespace EC
|
||||||
if(rhs == 0)
|
if(rhs == 0)
|
||||||
{
|
{
|
||||||
currentSize = 0;
|
currentSize = 0;
|
||||||
return changedQueue;
|
return changedVector;
|
||||||
}
|
}
|
||||||
changedQueue.push(std::make_tuple(false, rhs, 0));
|
changedVector.push_back(std::make_tuple(false, rhs, 0));
|
||||||
std::get<BitsetType>(entities[rhs]).reset();
|
std::get<BitsetType>(entities[rhs]).reset();
|
||||||
--rhs;
|
--rhs;
|
||||||
}
|
}
|
||||||
|
@ -365,8 +364,8 @@ namespace EC
|
||||||
// lhs is marked for deletion
|
// lhs is marked for deletion
|
||||||
|
|
||||||
// store deleted and changed id to queue
|
// store deleted and changed id to queue
|
||||||
changedQueue.push(std::make_tuple(false, lhs, 0));
|
changedVector.push_back(std::make_tuple(false, lhs, 0));
|
||||||
changedQueue.push(std::make_tuple(true, rhs, lhs));
|
changedVector.push_back(std::make_tuple(true, rhs, lhs));
|
||||||
|
|
||||||
// swap lhs entity with rhs entity
|
// swap lhs entity with rhs entity
|
||||||
std::swap(entities[lhs], entities.at(rhs));
|
std::swap(entities[lhs], entities.at(rhs));
|
||||||
|
@ -384,7 +383,7 @@ namespace EC
|
||||||
}
|
}
|
||||||
currentSize = rhs + 1;
|
currentSize = rhs + 1;
|
||||||
|
|
||||||
return changedQueue;
|
return changedVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -443,11 +443,10 @@ TEST(EC, DeletedEntityID)
|
||||||
manager.deleteEntity(e0);
|
manager.deleteEntity(e0);
|
||||||
manager.deleteEntity(e1);
|
manager.deleteEntity(e1);
|
||||||
|
|
||||||
auto changedQueue = manager.cleanup();
|
auto changedVector = manager.cleanup();
|
||||||
|
|
||||||
while(!changedQueue.empty())
|
for(const auto& t : changedVector)
|
||||||
{
|
{
|
||||||
auto t = changedQueue.front();
|
|
||||||
if(std::get<1>(t) == 0)
|
if(std::get<1>(t) == 0)
|
||||||
{
|
{
|
||||||
EXPECT_FALSE(std::get<0>(t));
|
EXPECT_FALSE(std::get<0>(t));
|
||||||
|
@ -460,7 +459,6 @@ TEST(EC, DeletedEntityID)
|
||||||
{
|
{
|
||||||
EXPECT_TRUE(std::get<0>(t));
|
EXPECT_TRUE(std::get<0>(t));
|
||||||
}
|
}
|
||||||
changedQueue.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_FALSE(manager.hasEntity(2));
|
EXPECT_FALSE(manager.hasEntity(2));
|
||||||
|
|
Loading…
Reference in a new issue