1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-07-31 13:11:48 +02:00

Improve searching for active entities. Also fix a possible crash because the entity instance pushed on the stack was appending to itself instead of the array.

This commit is contained in:
Sandu Liviu Catalin
2016-06-21 09:02:44 +03:00
parent 22fc6c54c2
commit 1d12ddd60d
10 changed files with 109 additions and 91 deletions

8
source/Base/Algo.cpp Normal file
View File

@@ -0,0 +1,8 @@
// ------------------------------------------------------------------------------------------------
#include "Base/Algo.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
} // Namespace:: SqMod

29
source/Base/Algo.hpp Normal file
View File

@@ -0,0 +1,29 @@
#ifndef _BASE_ALGO_HPP_
#define _BASE_ALGO_HPP_
// ------------------------------------------------------------------------------------------------
#include <SqBase.hpp>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
namespace Algo {
/* ------------------------------------------------------------------------------------------------
* Collect all elements within the specified range that the inspector deems worthy.
*/
template < typename Iterator, typename Inspector, typename Collector >
void Collect(Iterator first, Iterator last, Inspector inspect, Collector collect)
{
for (; first != last; ++first)
{
if (inspect(*first))
{
collect(*first);
}
}
}
} // Namespace:: Algo
} // Namespace:: SqMod
#endif // _BASE_ALGO_HPP_