tamer::tamerutil::ready_set< T, A > Class Template Reference

Utility class: A combination of set and queue. More...

#include <tamer/util.hh>

List of all members.

Public Types

typedef size_t size_type
typedef size_t index_type

Public Member Functions

 ready_set () throw ()
 Default constructor creates an empty ready_set.
 ~ready_set ()
 Destroy the ready_set.
size_t multiset_size () const throw ()
 Return number of elements in the multiset.
template<typename V>
index_type insert (const V &v)
 Insert element into the multiset.
template<typename V1, typename V2>
index_type insert (const V1 &v1, const V2 &v2)
 Insert element into the multiset.
void erase (index_type i)
 Remove element from the multiset.
void push_back_element (index_type i) throw ()
 Shift a multiset element to the end of the queue.
size_type size () const throw ()
 Return number of elements in the queue.
T * front_ptr () throw ()
 Return a pointer to the front element of the queue, if any.
void pop_front ()
 Remove the front element from the queue.
void clear ()
 Remove all elements from the multiset and the queue.


Detailed Description

template<typename T, typename A = std::allocator<ready_set_element<T> >>
class tamer::tamerutil::ready_set< T, A >

Utility class: A combination of set and queue.

A ready_set is a multiset coupled with a queue. Elements are allocated as part of the multiset. Allocation returns a unique index identifying the element. Later, the push_back_element function, which takes an index, shifts an element from the multiset to the end of the queue. front_ptr() and pop_front() operations operate on the queue.

The type T must have a usable copy constructor and a usable destructor.

The second template argument is an allocator for type ready_set_element<T>.


Member Function Documentation

template<typename T, typename A = std::allocator<ready_set_element<T> >>
size_t tamer::tamerutil::ready_set< T, A >::multiset_size (  )  const throw () [inline]

Return number of elements in the multiset.

Note:
Does not count elements in the associated queue.

template<typename T, typename A = std::allocator<ready_set_element<T> >>
template<typename V>
index_type tamer::tamerutil::ready_set< T, A >::insert ( const V &  v  )  [inline]

Insert element into the multiset.

Parameters:
v The element to insert (or any parameter to a T constructor).
Returns:
The new element's index.

template<typename T, typename A = std::allocator<ready_set_element<T> >>
template<typename V1, typename V2>
index_type tamer::tamerutil::ready_set< T, A >::insert ( const V1 &  v1,
const V2 &  v2 
) [inline]

Insert element into the multiset.

Parameters:
v1 First parameter to a two-argument T constructor.
v2 Second parameter to a two-argument T constructor.
Returns:
The new element's index.

template<typename T, typename A>
void tamer::tamerutil::ready_set< T, A >::erase ( index_type  i  )  [inline]

Remove element from the multiset.

Parameters:
i Index of element to remove. i must correspond to a current element of the multiset.

template<typename T, typename A>
void tamer::tamerutil::ready_set< T, A >::push_back_element ( index_type  i  )  throw () [inline]

Shift a multiset element to the end of the queue.

Parameters:
i Index of element to shift.

template<typename T, typename A = std::allocator<ready_set_element<T> >>
T* tamer::tamerutil::ready_set< T, A >::front_ptr (  )  throw () [inline]

Return a pointer to the front element of the queue, if any.

Returns:
Returns a null pointer if the queue is empty.

template<typename T, typename A>
void tamer::tamerutil::ready_set< T, A >::pop_front (  )  [inline]

Remove the front element from the queue.

Precondition:
The queue must not be empty.


The documentation for this class was generated from the following file:
Generated on Wed Aug 22 17:55:29 2007 for Tamer by  doxygen 1.5.1