_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

Public Types | Public Member Functions | Public Attributes | List of all members
CUnitCache Class Reference

#include <unit_cache.h>

Public Types

typedef std::vector< CUnit * >::iterator iterator
 
typedef std::vector< CUnit * >::const_iterator const_iterator
 

Public Member Functions

 CUnitCache ()
 
size_t size () const
 
void clear ()
 
const_iterator begin () const
 
iterator begin ()
 
const_iterator end () const
 
iterator end ()
 
CUnitoperator[] (const unsigned int index) const
 
CUnitoperator[] (const unsigned int index)
 
template<typename _T >
CUnitfind (const _T &pred) const
 Find the first unit in a tile cache for which a predicate is true. More...
 
template<typename _T >
void for_each (const _T functor)
 Apply a function to every element of a cache. More...
 
template<typename _T >
int for_each_if (const _T &functor)
 Apply a function to every element of a cache. More...
 
CUnitRemove (const unsigned int index)
 
bool Remove (CUnit *const unit)
 
void RemoveS (CUnit *const unit)
 
bool InsertS (CUnit *unit)
 
void Insert (CUnit *unit)
 

Public Attributes

std::vector< CUnit * > Units
 

Detailed Description

Unit cache

Member Typedef Documentation

◆ const_iterator

◆ iterator

typedef std::vector<CUnit *>::iterator CUnitCache::iterator

Constructor & Destructor Documentation

◆ CUnitCache()

CUnitCache::CUnitCache ( )
inline

Member Function Documentation

◆ begin() [1/2]

iterator CUnitCache::begin ( )
inline

◆ begin() [2/2]

const_iterator CUnitCache::begin ( ) const
inline

◆ clear()

void CUnitCache::clear ( )
inline

◆ end() [1/2]

iterator CUnitCache::end ( )
inline

◆ end() [2/2]

const_iterator CUnitCache::end ( ) const
inline

◆ find()

template<typename _T >
CUnit* CUnitCache::find ( const _T &  pred) const
inline

Find the first unit in a tile cache for which a predicate is true.

Parameters
predA predicate object vith bool operator()(const CUnit *).
Returns
The first unit u in the cache such that pred(u) is true, or NULL if no such unit exists.

◆ for_each()

template<typename _T >
void CUnitCache::for_each ( const _T  functor)
inline

Apply a function to every element of a cache.

Parameters
functorA unary function object vith void operator()(CUnit *).
Returns
count of visited element.

Applies the function object f to each element in the cache. functor must not modify the order of the cache.

◆ for_each_if()

template<typename _T >
int CUnitCache::for_each_if ( const _T &  functor)
inline

Apply a function to every element of a cache.

Parameters
functorA unary function object vith bool operator()(CUnit *).
Returns
count of visited element.

Applies the function object f to each element in the cache. functor must not modify the order of the cache. If functor return false then loop is exited.

◆ Insert()

void CUnitCache::Insert ( CUnit unit)
inline

Insert new unit into tile cache.

Parameters
unitUnit pointer to place in cache.

◆ InsertS()

bool CUnitCache::InsertS ( CUnit unit)
inline

Insert new unit into tile cache. Sorted version for binary searching.

Parameters
unitUnit pointer to place in cache.
Returns
false if unit is already in cache and nothing is added.

◆ operator[]() [1/2]

CUnit* CUnitCache::operator[] ( const unsigned int  index)
inline

◆ operator[]() [2/2]

CUnit* CUnitCache::operator[] ( const unsigned int  index) const
inline

◆ Remove() [1/2]

CUnit* CUnitCache::Remove ( const unsigned int  index)
inline

Remove unit on index from unit cache.

Parameters
indexUnit index to remove from container.
Returns
pointer to removed element.

◆ Remove() [2/2]

bool CUnitCache::Remove ( CUnit *const  unit)
inline

Remove unit from unit cache.

Parameters
unitUnit pointer to remove from container.

◆ RemoveS()

void CUnitCache::RemoveS ( CUnit *const  unit)
inline

Remove unit from unit cache.

Parameters
unitUnit pointer to remove from container.

◆ size()

size_t CUnitCache::size ( ) const
inline

Member Data Documentation

◆ Units

std::vector<CUnit *> CUnitCache::Units

The documentation for this class was generated from the following file:
(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.