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:
8
source/Base/Algo.cpp
Normal file
8
source/Base/Algo.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Base/Algo.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
|
||||
} // Namespace:: SqMod
|
29
source/Base/Algo.hpp
Normal file
29
source/Base/Algo.hpp
Normal 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_
|
Reference in New Issue
Block a user