ARGoS  3
A parallel, multi-engine simulator for swarm robotics
argos::CSet< T > Class Template Reference

Defines a very simple double-linked list that stores unique elements. More...

#include <set.h>

List of all members.

Classes

class  const_iterator

Public Types

typedef CSetIterator< T, T > iterator

Public Member Functions

 CSet ()
 Class constructor.
 CSet (const CSet &c_set)
 Class copy constructor.
 ~CSet ()
 Class destructor.
CSetoperator= (const CSet &c_set)
 Assignment operator.
bool empty () const
 Returns true if the list is empty.
size_t size () const
 Returns the number of elements in the list.
T & first ()
const T & first () const
T & last ()
const T & last () const
void insert (const T &t_element)
 Inserts an element to the list.
void erase (const T &t_element)
 Removes the passed element from the list.
void erase (iterator &c_it)
 Removes the passed element from the list.
void clear ()
 Erases the contents of the list.
bool exists (const T &t_element)
 Returns true if the given element is in the list.
iterator begin () const
 Returns an iterator to the first element.
iterator end () const
 Returns an invalid iterator.
iterator find (const T &t_element)
 Searches for an element in the list.

Detailed Description

template<class T>
class argos::CSet< T >

Defines a very simple double-linked list that stores unique elements.

The interface of this class is STL-compatible, but internally it behaves differently from standard containers. In fact, it only stores pointers to objects, and never copies them like STL containers do. The pointers are used to decide whether an element is already present in the list or not. Internally, The list is ordered by pointer.

See also:
SSetElement
CSetIterator

Definition at line 100 of file set.h.


Member Typedef Documentation

template<class T>
typedef CSetIterator<T, T> argos::CSet< T >::iterator

Definition at line 104 of file set.h.


Constructor & Destructor Documentation

template<class T>
argos::CSet< T >::CSet ( ) [inline]

Class constructor.

Creates an empty set.

Definition at line 123 of file set.h.

template<class T>
argos::CSet< T >::CSet ( const CSet< T > &  c_set) [inline]

Class copy constructor.

Creates a new set copying from the given set.

Parameters:
c_setThe set to copy from.

Definition at line 133 of file set.h.

template<class T>
argos::CSet< T >::~CSet ( ) [inline]

Class destructor.

Definition at line 143 of file set.h.


Member Function Documentation

template<class T>
iterator argos::CSet< T >::begin ( ) const [inline]

Returns an iterator to the first element.

Returns:
An iterator to the first element.

Definition at line 388 of file set.h.

template<class T>
void argos::CSet< T >::clear ( ) [inline]

Erases the contents of the list.

Definition at line 350 of file set.h.

template<class T>
bool argos::CSet< T >::empty ( ) const [inline]

Returns true if the list is empty.

Returns:
true if the list is empty.

Definition at line 202 of file set.h.

template<class T>
iterator argos::CSet< T >::end ( ) const [inline]

Returns an invalid iterator.

Returns:
An invalid iterator.

Definition at line 396 of file set.h.

template<class T>
void argos::CSet< T >::erase ( const T &  t_element) [inline]

Removes the passed element from the list.

Parameters:
t_elementThe element to remove.

Definition at line 287 of file set.h.

template<class T>
void argos::CSet< T >::erase ( iterator c_it) [inline]

Removes the passed element from the list.

Parameters:
t_itAn iterator to the element to remove.

Definition at line 343 of file set.h.

template<class T>
bool argos::CSet< T >::exists ( const T &  t_element) [inline]

Returns true if the given element is in the list.

Parameters:
t_elementThe element to search for.
Returns:
true if the given element is in the list.

Definition at line 380 of file set.h.

template<class T>
iterator argos::CSet< T >::find ( const T &  t_element) [inline]

Searches for an element in the list.

Returns:
An iterator to the element found.

Definition at line 404 of file set.h.

template<class T>
T& argos::CSet< T >::first ( ) [inline]

Definition at line 214 of file set.h.

template<class T>
const T& argos::CSet< T >::first ( ) const [inline]

Definition at line 218 of file set.h.

template<class T>
void argos::CSet< T >::insert ( const T &  t_element) [inline]

Inserts an element to the list.

The element is inserted only if not already present in the list.

Parameters:
t_elementThe element to insert.

Definition at line 235 of file set.h.

template<class T>
T& argos::CSet< T >::last ( ) [inline]

Definition at line 222 of file set.h.

template<class T>
const T& argos::CSet< T >::last ( ) const [inline]

Definition at line 226 of file set.h.

template<class T>
CSet& argos::CSet< T >::operator= ( const CSet< T > &  c_set) [inline]

Assignment operator.

Substitutes the contents of this set with those of the passed one.

Parameters:
c_setThe set to copy from.

Definition at line 152 of file set.h.

template<class T>
size_t argos::CSet< T >::size ( ) const [inline]

Returns the number of elements in the list.

Returns:
The number of elements in the list.

Definition at line 210 of file set.h.


The documentation for this class was generated from the following file: