_________ __ __
/ _____// |_____________ _/ |______ ____ __ __ ______
\_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
/ \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \
/_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
\/ \/ \//_____/ \/
______________________ ______________________
T H E W A R B E G I N S
Stratagus - A free fantasy real time strategy game engine
Go to the documentation of this file.
29 #ifndef __UNIT_CACHE_H__
30 #define __UNIT_CACHE_H__
53 typedef std::vector<CUnit *>::iterator
iterator;
88 std::vector<CUnit *>::const_iterator ret = std::find_if(
Units.begin(),
Units.end(), pred);
90 return ret !=
Units.end() ? (*ret) : NULL;
101 template<
typename _T>
106 for (
size_t i = 0; i !=
size; ++i) {
120 template<
typename _T>
125 for (
size_t count = 0; count !=
size; ++count) {
126 if (functor(
Units[count]) ==
false) {
159 #ifndef SECURE_UNIT_REMOVING
165 for (
unsigned int i = 0; i <
size; ++i) {
167 if (
Units[i] == unit) {
175 for (std::vector<CUnit *>::iterator i(
Units.begin()),
end(
Units.end()); i !=
end; ++i) {
192 for (std::vector<CUnit *>::iterator i(
Units.begin()),
end(
Units.end()); i !=
end; ++i) {
209 if (!binary_search(
Units.begin(),
Units.end(), unit)) {
210 Units.insert(std::lower_bound(
Units.begin(),
Units.end(), unit), unit);
223 Units.push_back(unit);
233 #endif // !__UNIT_CACHE_H__
const_iterator end() const
Definition: unit_cache.h:65
void clear()
Definition: unit_cache.h:61
Definition: unit_cache.h:50
void Insert(CUnit *unit)
Definition: unit_cache.h:221
iterator end()
Definition: unit_cache.h:66
void for_each(const _T functor)
Apply a function to every element of a cache.
Definition: unit_cache.h:102
CUnit * find(const _T &pred) const
Find the first unit in a tile cache for which a predicate is true.
Definition: unit_cache.h:86
bool InsertS(CUnit *unit)
Definition: unit_cache.h:207
std::vector< CUnit * > Units
Definition: unit_cache.h:227
CUnitCache()
Definition: unit_cache.h:57
std::vector< CUnit * >::const_iterator const_iterator
Definition: unit_cache.h:54
iterator begin()
Definition: unit_cache.h:64
CUnit * Remove(const unsigned int index)
Definition: unit_cache.h:140
size_t size() const
Definition: unit_cache.h:59
void RemoveS(CUnit *const unit)
Definition: unit_cache.h:190
CUnit * operator[](const unsigned int index) const
Definition: unit_cache.h:68
bool Remove(CUnit *const unit)
Definition: unit_cache.h:157
Describes the world map.
Definition: map.h:154
int for_each_if(const _T &functor)
Apply a function to every element of a cache.
Definition: unit_cache.h:121
#define Assert(cond)
Definition: stratagus.h:142
std::vector< CUnit * >::iterator iterator
Definition: unit_cache.h:53
The big unit structure.
Definition: unit.h:135
CUnit * operator[](const unsigned int index)
Definition: unit_cache.h:73
const_iterator begin() const
Definition: unit_cache.h:63
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.