38 template<
class CONTAINED_TYPE,
class REFERENCED_TYPE>
100 template <
class T,
class C = std::less<T> >
160 if(! c_set.
empty()) {
163 m_unSize = c_set.m_unSize;
169 m_psLast = m_psFirst;
181 while(psCurElemOnOther != NULL) {
185 psLastElemOnThis->
Next = psCurElemOnThis;
187 psLastElemOnThis = psCurElemOnThis;
189 psCurElemOnOther = psCurElemOnOther->
Next;
192 m_psLast = psCurElemOnThis;
204 return m_unSize == 0;
216 return m_psFirst->Data;
220 return m_psFirst->Data;
224 return m_psLast->Data;
228 return m_psLast->Data;
236 void insert(
const T& t_element, C comp = C()) {
241 m_psLast = m_psFirst;
249 while(psNextElem != NULL &&
250 comp(psNextElem->
Data, t_element)) {
251 psNextElem = psNextElem->
Next;
254 if(psNextElem == NULL) {
257 m_psLast->Next = psNewElem;
258 m_psLast = psNewElem;
263 if(psNextElem->
Data == t_element) {
268 if(psNextElem == m_psFirst) {
271 m_psFirst->Previous = psNewElem;
272 m_psFirst = psNewElem;
297 if(m_psFirst->Data == t_element) {
314 if(psElem == m_psFirst) {
316 m_psFirst = m_psFirst->Next;
317 m_psFirst->Previous = NULL;
323 if(psElem == m_psLast) {
325 m_psLast = m_psLast->Previous;
326 m_psLast->Next = NULL;
364 while(psCurElem != NULL) {
366 psCurElem = psNextElem;
367 if(psCurElem != NULL) {
368 psNextElem = psNextElem->
Next;
382 return find_impl(t_element) != NULL;
406 return iterator(find_impl(t_element));
411 SSetElement<T>* find_impl(
const T& t_element, C comp = C())
const {
412 if(m_psFirst == NULL) {
415 SSetElement<T>* psElem = m_psFirst;
416 while(psElem != NULL &&
417 comp(psElem->Data, t_element)) {
418 psElem = psElem->Next;
424 return (psElem->Data == t_element) ? psElem : NULL;
430 SSetElement<T>* m_psFirst;
431 SSetElement<T>* m_psLast;
The namespace containing all the ARGoS related code.
The data container of CSet.
SSetElement(const T &t_data, SSetElement *ps_prev=NULL, SSetElement *ps_next=NULL)
bool operator==(const CSetIterator &c_it)
CSetIterator & operator=(const CSetIterator &c_it)
CSetIterator(SSetElement< CONTAINED_TYPE > *ps_elem=NULL)
REFERENCED_TYPE value_type
CSetIterator(const CSetIterator &c_it)
std::forward_iterator_tag iterator_category
bool operator!=(const CSetIterator &c_it)
std::ptrdiff_t difference_type
REFERENCED_TYPE & reference
SSetElement< CONTAINED_TYPE > * m_psElem
CSetIterator & operator++()
REFERENCED_TYPE * pointer
Defines a very simple double-linked list that stores unique elements.
void erase(iterator &c_it)
Removes the passed element from the list.
void erase(const T &t_element)
Removes the passed element from the list.
CSet(const CSet &c_set)
Class copy constructor.
size_t size() const
Returns the number of elements in the list.
iterator find(const T &t_element)
Searches for an element in the list.
bool empty() const
Returns true if the list is empty.
iterator begin() const
Returns an iterator to the first element.
bool exists(const T &t_element)
Returns true if the given element is in the list.
void clear()
Erases the contents of the list.
CSetIterator< T, T > iterator
CSet & operator=(const CSet &c_set)
Assignment operator.
void insert(const T &t_element, C comp=C())
Inserts an element to the list.
iterator end() const
Returns an invalid iterator.
bool operator!=(const iterator &c_it)
bool operator==(const iterator &c_it)
const_iterator & operator=(const iterator &c_it)
const_iterator(const iterator &c_it)