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;
278 psNextElem->
Previous->Next = 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;
397 inline iterator
end()
const {
405 inline iterator
find(
const T& t_element) {
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;
bool operator==(const iterator &c_it)
REFERENCED_TYPE * pointer
CSetIterator & operator++()
REFERENCED_TYPE value_type
void insert(const T &t_element, C comp=C())
Inserts an element to the list.
void clear()
Erases the contents of the list.
SSetElement< CONTAINED_TYPE > * m_psElem
Defines a very simple double-linked list that stores unique elements.
void erase(const T &t_element)
Removes the passed element from the list.
REFERENCED_TYPE & reference
iterator find(const T &t_element)
Searches for an element in the list.
bool operator!=(const CSetIterator &c_it)
SSetElement(const T &t_data, SSetElement *ps_prev=NULL, SSetElement *ps_next=NULL)
bool empty() const
Returns true if the list is empty.
CSet(const CSet &c_set)
Class copy constructor.
CSetIterator(const CSetIterator &c_it)
const_iterator(const iterator &c_it)
CSet & operator=(const CSet &c_set)
Assignment operator.
CSetIterator & operator=(const CSetIterator &c_it)
std::forward_iterator_tag iterator_category
CSetIterator< T, T > iterator
std::ptrdiff_t difference_type
void erase(iterator &c_it)
Removes the passed element from the list.
The data container of CSet.
size_t size() const
Returns the number of elements in the list.
The namespace containing all the ARGoS related code.
iterator begin() const
Returns an iterator to the first element.
bool operator!=(const iterator &c_it)
iterator end() const
Returns an invalid iterator.
bool exists(const T &t_element)
Returns true if the given element is in the list.
CSetIterator(SSetElement< CONTAINED_TYPE > *ps_elem=NULL)
const_iterator & operator=(const iterator &c_it)
bool operator==(const CSetIterator &c_it)