Matrix::Item Class Reference

Item in the matrix array. More...

List of all members.

Public Types

typedef std::list< Object * > Container
 Used container.
typedef Container::size_type SizeType
 Size type of the item.

Public Member Functions

 Item ()
 Default constructor - empty container will be created.
 ~Item ()
 Destructor- removes all objects from the item.
ObjectGetTopObject () const
 Returns pointer to the "top" object in the container.
void AddObject (Object *object)
 Adds selected object to the container according to his priority.
bool RemoveObject (Object::Priority priority, bool freeMemory=true)
 Removes object with selected priority from the container.
bool RemoveTopObject (bool freeMemory=true)
 Removes "top" object from the container.
void RemoveAllObjects (bool freeMemory=true)
 Removes all objects from the container.
bool IsThereObject () const
 Returns true if there is an object in the container.
template<class Function>
void ApplyFunctionToEachObject (Function func, bool reversedPass=false)
 Applies the unary function func to each of the elements in the container.
template<class Predicate>
void RemoveObjectsAccToPredicate (Predicate pred)
 Removes all elements in the container for which the predicate pred returns true.

Private Attributes

Container container
 Container.


Detailed Description

Item in the matrix array.

These items will contain objects that can be on the one place at the same time (e.g trail and agent).


Member Typedef Documentation

std::list< Object * > Matrix::Item::Container

Used container.

typedef Container::size_type Matrix::Item::SizeType

Size type of the item.


Constructor & Destructor Documentation

Matrix::Item::Item (  )  [inline]

Default constructor - empty container will be created.

Matrix::Item::~Item (  )  [inline]

Destructor- removes all objects from the item.


Member Function Documentation

void Matrix::Item::AddObject ( Object object  ) 

Adds selected object to the container according to his priority.

Parameters:
object Object that has to be added into container
If there already is an object with the same priority and cannot be in the container more then once then the selected object will replace it.

template<class Function>
void Matrix::Item::ApplyFunctionToEachObject ( Function  func,
bool  reversedPass = false 
) [inline]

Applies the unary function func to each of the elements in the container.

Parameters:
func Unary function that has to be applied
reversedPass If true, container will be passed reversed

Object* Matrix::Item::GetTopObject (  )  const [inline]

Returns pointer to the "top" object in the container.

If there is no object in the container it returns 0

bool Matrix::Item::IsThereObject (  )  const [inline]

Returns true if there is an object in the container.

void Matrix::Item::RemoveAllObjects ( bool  freeMemory = true  ) 

Removes all objects from the container.

Parameters:
freeMemory If true object's memory will be freed

bool Matrix::Item::RemoveObject ( Object::Priority  priority,
bool  freeMemory = true 
)

Removes object with selected priority from the container.

Returns:
Returns true if some object was removed
Parameters:
priority Object's priority
freeMemory If true object's memory will be freed
If there are more objects with the same priority only the "first" one (that's on the "top") is removed.

template<class Predicate>
void Matrix::Item::RemoveObjectsAccToPredicate ( Predicate  pred  )  [inline]

Removes all elements in the container for which the predicate pred returns true.

Parameters:
pred Predicate that returns true/false

bool Matrix::Item::RemoveTopObject ( bool  freeMemory = true  ) 

Removes "top" object from the container.

Parameters:
freeMemory If true object's memory will be freed
Returns:
Returns true if some object was removed


Member Data Documentation

Container Matrix::Item::container [private]

Container.


The documentation for this class was generated from the following files:
Generated on Sun Apr 29 11:46:11 2007 for IPP/ICP2007 by  doxygen 1.4.7