eosim::utils::EntityQueueOrdered Class Reference
[Collections]

#include <eosim/utils/entityqueueordered.hpp>

Inheritance diagram for eosim::utils::EntityQueueOrdered:

Inheritance graph
[legend]
Collaboration diagram for eosim::utils::EntityQueueOrdered:

Collaboration graph
[legend]
List of all members.

Detailed Description

Ordered Queue of Entities.

Author:
Sebastián Alaggia
Version:
1.0.1
Date:
2005
This is a ordered queue of entities. The queue is ordered according to the comparator given in the constructor, in a way that comparator.compare(q1,q2) is true when q1 an element of the queue and q2 the following.


Public Member Functions

 EntityQueueOrdered (core::EntityComp *comp)
 The constructor creates an empty EntityQueueOrdered.
 ~EntityQueueOrdered ()
 The destructor of EntityQueueOrdered.
void push (core::Entity *ent)
 This operation adds ent according to the comparator given in the constructor.
core::Entitypop ()
 This operation returns and remove the first entity in the queue.
void remove (unsigned int i)
 This operation removes the entity whose position is i.
bool empty ()
 This operation returns 1 if the queue is empty.
core::Entityoperator[] (unsigned int i)
 This operation returns the entity whose position is i.
unsigned int size ()
 This operation returns the size of the queue.


Constructor & Destructor Documentation

EntityQueueOrdered::EntityQueueOrdered ( core::EntityComp comp  ) 

The constructor creates an empty EntityQueueOrdered.

Note:
comp defines the order of the queue


Member Function Documentation

void EntityQueueOrdered::push ( core::Entity ent  )  [virtual]

This operation adds ent according to the comparator given in the constructor.

Note:
The queue is implemented using a std::deque. That give us O(1) when accessing an element and inserting in the back and front. But O(n) when inserting in the midle.

We use binary search to find were to insert, but the insertion is the bottle neck of this operation.

Implements eosim::utils::EntityQueue.

Entity * EntityQueueOrdered::pop (  )  [virtual]

This operation returns and remove the first entity in the queue.

Warning:
The queue is must not be empty.

Implements eosim::utils::EntityQueue.

void EntityQueueOrdered::remove ( unsigned int  i  )  [virtual]

This operation removes the entity whose position is i.

Warning:
i must be within the limits of the queue.

Implements eosim::utils::EntityQueue.

Entity * EntityQueueOrdered::operator[] ( unsigned int  i  )  [virtual]

This operation returns the entity whose position is i.

Warning:
i must be within the limits of the queue.

Implements eosim::utils::EntityQueue.


Generated on Tue Oct 14 16:49:10 2008 for EOSimulator by  doxygen 1.5.2