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

CUnitCache Struct Reference

#include <unit_cache.h>

List of all members.


Public Member Functions

 CUnitCache ()
size_t size () const
void clear ()
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 chache for which a predicate is true.
template<typename _T>
void for_each (_T functor)
 Apply a function to every element of a cache.
template<typename _T>
int for_each_if (_T &functor)
 Apply a function to every element of a cache.
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

Constructor & Destructor Documentation

CUnitCache::CUnitCache (  )  [inline]


Member Function Documentation

size_t CUnitCache::size (  )  const [inline]

void CUnitCache::clear (  )  [inline]

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

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

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

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

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

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

Apply a function to every element of a cache.

Parameters:
functor A 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.

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

Apply a function to every element of a cache.

Parameters:
functor A 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.

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

Remove unit on index from unit cache.

Parameters:
index Unit index to remove from container.
Returns:
pointer to removed element.

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

Remove unit from unit cache.

Parameters:
unit Unit pointer to remove from container.

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

Remove unit from unit cache.

Parameters:
unit Unit pointer to remove from container.

bool CUnitCache::InsertS ( CUnit unit  )  [inline]

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

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

void CUnitCache::Insert ( CUnit unit  )  [inline]

Insert new unit into tile cache.

Parameters:
unit Unit pointer to place in cache.


Member Data Documentation

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


The documentation for this struct was generated from the following file:
(C) Copyright 1998-2011 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.