argos::CSet< T, C > Class Template Reference

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

#include <set.h>

Classes

class  const_iterator
 

Public Types

typedef CSetIterator< T, T > iterator
 

Public Member Functions

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

Detailed Description

template<class T, class C = std::less<T>>
class argos::CSet< T, C >

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 using the comparator C. By default, the comparator uses the pointer values.

See also
SSetElement
CSetIterator

Definition at line 101 of file set.h.

Member Typedef Documentation

template<class T, class C = std::less<T>>
typedef CSetIterator<T, T> argos::CSet< T, C >::iterator

Definition at line 105 of file set.h.

Constructor & Destructor Documentation

template<class T, class C = std::less<T>>
argos::CSet< T, C >::CSet ( )
inline

Class constructor.

Creates an empty set.

Definition at line 124 of file set.h.

template<class T, class C = std::less<T>>
argos::CSet< T, C >::CSet ( const CSet< T, C > &  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 134 of file set.h.

template<class T, class C = std::less<T>>
argos::CSet< T, C >::~CSet ( )
inline

Class destructor.

Definition at line 144 of file set.h.

Member Function Documentation

template<class T, class C = std::less<T>>
iterator argos::CSet< T, C >::begin ( ) const
inline

Returns an iterator to the first element.

Returns
An iterator to the first element.

Definition at line 389 of file set.h.

template<class T, class C = std::less<T>>
void argos::CSet< T, C >::clear ( )
inline

Erases the contents of the list.

Definition at line 351 of file set.h.

template<class T, class C = std::less<T>>
bool argos::CSet< T, C >::empty ( ) const
inline

Returns true if the list is empty.

Returns
true if the list is empty.

Definition at line 203 of file set.h.

template<class T, class C = std::less<T>>
iterator argos::CSet< T, C >::end ( ) const
inline

Returns an invalid iterator.

Returns
An invalid iterator.

Definition at line 397 of file set.h.

template<class T, class C = std::less<T>>
void argos::CSet< T, C >::erase ( const T &  t_element)
inline

Removes the passed element from the list.

Parameters
t_elementThe element to remove.

Definition at line 288 of file set.h.

template<class T, class C = std::less<T>>
void argos::CSet< T, C >::erase ( iterator c_it)
inline

Removes the passed element from the list.

Parameters
t_itAn iterator to the element to remove.

Definition at line 344 of file set.h.

template<class T, class C = std::less<T>>
bool argos::CSet< T, C >::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 381 of file set.h.

template<class T, class C = std::less<T>>
iterator argos::CSet< T, C >::find ( const T &  t_element)
inline

Searches for an element in the list.

Returns
An iterator to the element found.

Definition at line 405 of file set.h.

template<class T, class C = std::less<T>>
T& argos::CSet< T, C >::first ( )
inline

Definition at line 215 of file set.h.

template<class T, class C = std::less<T>>
const T& argos::CSet< T, C >::first ( ) const
inline

Definition at line 219 of file set.h.

template<class T, class C = std::less<T>>
void argos::CSet< T, C >::insert ( const T &  t_element,
comp = C() 
)
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 236 of file set.h.

template<class T, class C = std::less<T>>
T& argos::CSet< T, C >::last ( )
inline

Definition at line 223 of file set.h.

template<class T, class C = std::less<T>>
const T& argos::CSet< T, C >::last ( ) const
inline

Definition at line 227 of file set.h.

template<class T, class C = std::less<T>>
CSet& argos::CSet< T, C >::operator= ( const CSet< T, C > &  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 153 of file set.h.

template<class T, class C = std::less<T>>
size_t argos::CSet< T, C >::size ( ) const
inline

Returns the number of elements in the list.

Returns
The number of elements in the list.

Definition at line 211 of file set.h.