Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
elm::genstruct::SLList< T, E > Class Template Reference

#include <elm/genstruct/SLList.h>

Classes

class  Iterator
 
class  MutableIterator
 

Public Member Functions

 SLList (void)
 
 SLList (const SLList &list)
 
SLListoperator= (const SLList &list)
 
 ~SLList (void)
 
void copy (const SLList< T > &list)
 
int count (void) const
 
bool contains (const T &item) const
 
bool isEmpty (void) const
 
 operator bool (void) const
 
void clear (void)
 
void add (const T &value)
 
template<class C >
void addAll (const C &items)
 
template<class C >
void removeAll (const C &items)
 
void remove (const T &value)
 
void remove (Iterator &iter)
 
void remove (MutableIterator &iter)
 
T & first (void)
 
const T & first (void) const
 
T & last (void)
 
const T & last (void) const
 
Iterator find (const T &item) const
 
Iterator find (const T &item, const Iterator &pos) const
 
void addFirst (const T &value)
 
void addLast (const T &value)
 
void addAfter (const Iterator &pos, const T &value)
 
void addBefore (const Iterator &pos, const T &value)
 
void removeFirst (void)
 
void removeLast (void)
 
void set (const Iterator &pos, const T &item)
 
const T & top (void) const
 
pop (void)
 
void push (const T &i)
 
void reset (void)
 
SLList< T > & operator+= (const T &h)
 
SLList< T > & operator+= (const SLList< T > &l)
 

Static Public Attributes

static SLList< T, E > null
 

Detailed Description

template<class T, class E = Equiv<T>>
class elm::genstruct::SLList< T, E >

This class provides a generic implementation of single-link lists.

Implemented concepts:
elm::concept::MutableList
Parameters
TType of data stored in the list.
EEquivallence class to compare items of the list.

Constructor & Destructor Documentation

template<class T, class E = Equiv<T>>
elm::genstruct::SLList< T, E >::SLList ( void  )
template<class T, class E = Equiv<T>>
elm::genstruct::SLList< T, E >::SLList ( const SLList< T, E > &  list)
template<class T, class E = Equiv<T>>
elm::genstruct::SLList< T, E >::~SLList ( void  )

Member Function Documentation

template<class T, class E = Equiv<T>>
void elm::genstruct::SLList< T, E >::add ( const T &  value)
template<class T, class E = Equiv<T>>
void elm::genstruct::SLList< T, E >::addAfter ( const Iterator pos,
const T &  value 
)

Add an item after the one pointed by pos.

Parameters
posIterator pointing the element to add after.
valueValue to add.
Warning
pos must not point at the end of the list!
template<class T, class E = Equiv<T>>
template<class C >
void elm::genstruct::SLList< T, E >::addAll ( const C &  items)
template<class T, class E = Equiv<T>>
void elm::genstruct::SLList< T, E >::addBefore ( const Iterator pos,
const T &  value 
)

Add item before the element pointer by pos.

Parameters
posIterator pointing the element to add before.
valueValue to add.
Warning
pos must not point at the end of the list!

Referenced by elm::SortedList< pair_t, DelegateComparator< pair_t, AssocComparator< string, Section *, C > > >::add().

template<class T, class E = Equiv<T>>
void elm::genstruct::SLList< T, E >::addLast ( const T &  item)

Add the given item at the last position in the list. Remark that this method is really inefficient. Its working time is in O(n), n number of nodes in the list. Use it only with small list or revert to more powerful data structures.

Parameters
itemItem to add.

Referenced by elm::SortedList< pair_t, DelegateComparator< pair_t, AssocComparator< string, Section *, C > > >::add().

template<class T, class E = Equiv<T>>
bool elm::genstruct::SLList< T, E >::contains ( const T &  item) const

Test if an item is in the list.

Parameters
itemItem to look for.
Returns
True if the item is the list, false else.
template<class T, class E = Equiv<T>>
void elm::genstruct::SLList< T, E >::copy ( const SLList< T > &  list)
template<class T, class E = Equiv<T>>
int elm::genstruct::SLList< T, E >::count ( void  ) const
template<class T, class E = Equiv<T>>
Iterator elm::genstruct::SLList< T, E >::find ( const T &  item) const

Find an element in the list.

Parameters
itemElement to look for.
Returns
Iterator on the found element or iterator on the list end.

Referenced by elm::SortedList< pair_t, DelegateComparator< pair_t, AssocComparator< string, Section *, C > > >::find().

template<class T, class E = Equiv<T>>
Iterator elm::genstruct::SLList< T, E >::find ( const T &  item,
const Iterator pos 
) const

Find an element in the list from the given position.

Parameters
itemElement to look for.
posPosition to look from.
Returns
Iterator on the found element or iterator on the list end.
template<class T, class E = Equiv<T>>
const T & elm::genstruct::SLList< T, E >::first ( void  ) const

Get the first item of the list.

Returns
First item.
Warning
It is an error to call this method if the list is empty.
template<class T, class E = Equiv<T>>
T& elm::genstruct::SLList< T, E >::last ( void  )
template<class T, class E = Equiv<T>>
const T & elm::genstruct::SLList< T, E >::last ( void  ) const

Get the last item of the list. Remark that this method is really inefficient. Its working time is in O(n), n number of nodes in the list. Use it only with small list or revert to more powerful data structures.

Returns
Last item.
Warning
It is an error to call this method if the list is empty.
template<class T, class E = Equiv<T>>
elm::genstruct::SLList< T, E >::operator bool ( void  ) const
template<class T, class E = Equiv<T>>
SLList<T>& elm::genstruct::SLList< T, E >::operator+= ( const T &  h)
template<class T, class E = Equiv<T>>
SLList<T>& elm::genstruct::SLList< T, E >::operator+= ( const SLList< T > &  l)
template<class T, class E = Equiv<T>>
SLList& elm::genstruct::SLList< T, E >::operator= ( const SLList< T, E > &  list)
template<class T, class E = Equiv<T>>
T elm::genstruct::SLList< T, E >::pop ( void  )
template<class T, class E = Equiv<T>>
void elm::genstruct::SLList< T, E >::push ( const T &  i)
template<class T, class E = Equiv<T>>
void elm::genstruct::SLList< T, E >::remove ( const T &  item)

Remove the given item from the list or just one if the list contains many items equals to the given one. The item type T must support the equality / inequality operators.

Warning
This method may break iterator work!
Parameters
itemItem to remove.

Referenced by elm::SortedList< pair_t, DelegateComparator< pair_t, AssocComparator< string, Section *, C > > >::remove().

template<class T, class E = Equiv<T>>
void elm::genstruct::SLList< T, E >::remove ( Iterator iter)

Remove the item pointed by the iterator. After this call, the iterator points to the next item (if any).

Parameters
iterIterator pointing the item to remove.
Warning
The iterator must point to an actual item, not at the end of the list.
template<class T, class E = Equiv<T>>
void elm::genstruct::SLList< T, E >::remove ( MutableIterator iter)
template<class T, class E = Equiv<T>>
template<class C >
void elm::genstruct::SLList< T, E >::removeAll ( const C &  items)
template<class T, class E = Equiv<T>>
void elm::genstruct::SLList< T, E >::removeLast ( void  )

Remove the last item from the list. Remark that this method is really inefficient. Its working time is in O(n), n number of nodes in the list. Use it only with small list or revert to more powerful data structures.

Warning
It is an error to call this method if the list is empty.
This method may break iterator work!

Referenced by elm::SortedList< pair_t, DelegateComparator< pair_t, AssocComparator< string, Section *, C > > >::removeLast().

template<class T, class E = Equiv<T>>
void elm::genstruct::SLList< T, E >::reset ( void  )
template<class T, class E = Equiv<T>>
void elm::genstruct::SLList< T, E >::set ( const Iterator pos,
const T &  item 
)

change the value of an element of the list.

Parameters
posIterator on the element to set.
itemValue to set.
Warning
The iterator must point to an actual element, not the end of the list.
template<class T, class E = Equiv<T>>
const T& elm::genstruct::SLList< T, E >::top ( void  ) const

Member Data Documentation

template<class T, class E = Equiv<T>>
SLList< T, E > elm::genstruct::SLList< T, E >::null
static

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