CircularList< T > Class Template Reference

Simu5G: CircularList< T > Class Template Reference
Simu5G
CircularList< T > Class Template Reference

#include <Circular.h>

Public Member Functions

 CircularList ()
 Create an empty circular list.
 CircularList (const CircularList< T > &cl)
 Copy constructor.
CircularList & operator= (const CircularList< T > &cl)
 Assignment operator.
bool empty ()
 Return true if the list is empty.
unsigned int size ()
 Return the number of elements.
void clear ()
 Removes all the elements in the list.
bool find (const T &t)
 Return true if a given element is in the list.
T & find (T &t, bool &valid)
 Finds an element in the list and return it.
void insert (const T &t)
 Insert a new element before the current position.
void erase ()
 Removes the element at the current position.
void eraseElem (T &t)
 Erases the specified element (eventually the current position is shifted)
void rewind ()
 Goes back to the beginning of the circular list.
void move ()
 Moves the pointer to the next element in a circular fashion.
const T & current () const
 Return the current element.
T & current ()
 Return the current element.
void insertFront (const T &t)
 Insert a new element after the current position.

Detailed Description

template<typename T>
class simu5g::CircularList< T >

Circular list of elements.

Constructor & Destructor Documentation

◆ CircularList() [1/2]

template<typename T>
CircularList ( )
inline

Create an empty circular list.

◆ CircularList() [2/2]

template<typename T>
CircularList ( const CircularList< T > & cl)
inline

Copy constructor.

Member Function Documentation

◆ operator=()

template<typename T>
CircularList & operator= ( const CircularList< T > & cl)
inline

Assignment operator.

◆ empty()

template<typename T>
bool empty ( )
inline

Return true if the list is empty.

◆ size()

template<typename T>
unsigned int size ( )
inline

Return the number of elements.

◆ clear()

template<typename T>
void clear ( )
inline

Removes all the elements in the list.

◆ find() [1/2]

template<typename T>
bool find ( const T & t)
inline

Return true if a given element is in the list.

◆ find() [2/2]

template<typename T>
T & find ( T & t,
bool & valid )
inline

Finds an element in the list and return it.

The element returned is only meaningful if valid == true.

◆ insert()

template<typename T>
void insert ( const T & t)
inline

Insert a new element before the current position.

◆ erase()

template<typename T>
void erase ( )
inline

Removes the element at the current position.

◆ eraseElem()

template<typename T>
void eraseElem ( T & t)
inline

Erases the specified element (eventually the current position is shifted)

◆ rewind()

template<typename T>
void rewind ( )
inline

Goes back to the beginning of the circular list.

◆ move()

template<typename T>
void move ( )
inline

Moves the pointer to the next element in a circular fashion.

◆ current() [1/2]

template<typename T>
const T & current ( ) const
inline

Return the current element.

If the size is 0, then the return value is not meaningful, and may also crash program execution. We use an assert here since we do not want to use exceptions, which would be the right thing to do.

◆ current() [2/2]

template<typename T>
T & current ( )
inline

Return the current element.

◆ insertFront()

template<typename T>
void insertFront ( const T & t)
inline

Insert a new element after the current position.