Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
List< T, E, A > Class Template Reference

#include <elm/data/List.h>

+ Inheritance diagram for List< T, E, A >:

Classes

class  Iter
 
class  PrecIter
 
class  SubIter
 

Public Member Functions

 List ()
 
 List (const List< T, E, A > &list)
 
 ~List (void)
 
E & equivalence ()
 
const E & equivalence () const
 
A & allocator ()
 
void copy (const List< T, E, A > &list)
 
Iter items (void) const
 
Iter operator* (void) const
 
 operator Iter (void) const
 
Iter begin (void) const
 
Iter end (void) const
 
int count (void) const
 
bool contains (const T &item) const
 
bool isEmpty (void) const
 
 operator bool (void) const
 
bool equals (const List< T > &l) const
 
const T & at (const Iter &i) 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)
 
T & at (const Iter &i)
 
void remove (PrecIter &iter)
 
T & first (void)
 
const T & first (void) const
 
T & last (void)
 
const T & last (void) const
 
T & nth (int n)
 
const T & nth (int n) const
 
Iter find (const T &item) const
 
Iter find (const T &item, const Iter &pos) const
 
void addFirst (const T &value)
 
void addLast (const T &value)
 
void addAfter (const Iter &pos, const T &value)
 
void addBefore (PrecIter &pos, const T &value)
 
void removeFirst (void)
 
void removeLast (void)
 
void set (const Iter &pos, const T &item)
 
const T & top (void) const
 
pop (void)
 
void push (const T &i)
 
void reset (void)
 
Listoperator= (const List &list)
 
bool operator& (const T &e) const
 
T & operator[] (int k)
 
const T & operator[] (int k) const
 
bool operator== (const List< T > &l) const
 
bool operator!= (const List< T > &l) const
 
List< T > & operator+= (const T &h)
 
List< T > & operator+= (const List< T > &l)
 
List< T > & operator-= (const T &h)
 
List< T > & operator-= (const List< T > &l)
 
- Public Member Functions inherited from Equiv< T >
bool isEqual (const T &v1, const T &v2) const
 
- Public Member Functions inherited from DefaultAllocatorDelegate
t::ptr allocate (t::size size) const
 
void free (t::ptr p) const
 
template<class T >
T * alloc () const
 

Static Public Attributes

static List< T, E, A > null
 
- Static Public Attributes inherited from Equiv< T >
static Equiv< T > def
 

Additional Inherited Members

- Public Types inherited from Equiv< T >
typedef T t
 
- Static Public Member Functions inherited from Equiv< T >
static bool equals (const T &v1, const T &v2)
 

Detailed Description

template<class T, class E = Equiv<T>, class A = DefaultAlloc>
class elm::List< T, E, A >

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

Performances
  • addition – O(1)
  • removal – O(n)
  • find – O(n)
  • memory – 2 pointers + 1 pointer / element
Implemented concepts:
Parameters
TType of data stored in the list.
MManager supporting equivallence and allocation.

Constructor & Destructor Documentation

◆ List() [1/2]

List ( )
inline

◆ List() [2/2]

List ( const List< T, E, A > &  list)
inline

◆ ~List()

~List ( void  )
inline

Member Function Documentation

◆ add()

◆ addAfter()

void addAfter ( const Iter pos,
const T &  value 
)
inline

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!

◆ addAll()

◆ addBefore()

void addBefore ( PrecIter pos,
const T &  value 
)
inline

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 SortedList< Pair< string, Section * >, AssocComparator< string, Section *, Comparator< string > >, DefaultAlloc >::add(), and ListSet< T, C, A >::join().

◆ addFirst()

◆ addLast()

void addLast ( const T &  item)
inline

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 SortedList< Pair< string, Section * >, AssocComparator< string, Section *, Comparator< string > >, DefaultAlloc >::add().

◆ allocator()

◆ at() [1/2]

T& at ( const Iter i)
inline

◆ at() [2/2]

◆ begin()

Iter begin ( void  ) const
inline

◆ clear()

◆ contains()

bool contains ( const T &  item) const
inline

◆ copy()

◆ count()

int count ( void  ) const
inline

◆ end()

List::iter end ( void  ) const
inline

Get an iterator on the end of the list.

Returns
Ending iterator.

◆ equals()

bool equals ( const List< T > &  l) const
inline

◆ equivalence() [1/2]

◆ equivalence() [2/2]

const E& equivalence ( ) const
inline

◆ find() [1/2]

prec_iter find ( const T &  item) const
inline

Find an element in the list.

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

◆ find() [2/2]

Iter find ( const T &  item,
const Iter pos 
) const
inline

◆ first() [1/2]

◆ first() [2/2]

const T & first ( void  ) const
inline

Get the first item of the list.

Returns
First item.
Warning
It is an error to call this method if the list is empty.

◆ isEmpty()

◆ items()

◆ last() [1/2]

◆ last() [2/2]

const T & last ( void  ) const
inline

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.

◆ nth() [1/2]

◆ nth() [2/2]

const T& nth ( int  n) const
inline

◆ operator bool()

operator bool ( void  ) const
inline

◆ operator Iter()

operator Iter ( void  ) const
inline

◆ operator!=()

bool operator!= ( const List< T > &  l) const
inline

◆ operator&()

bool operator& ( const T &  e) const
inline

◆ operator*()

Iter operator* ( void  ) const
inline

◆ operator+=() [1/2]

List<T>& operator+= ( const List< T > &  l)
inline

◆ operator+=() [2/2]

List<T>& operator+= ( const T &  h)
inline

◆ operator-=() [1/2]

List<T>& operator-= ( const List< T > &  l)
inline

◆ operator-=() [2/2]

List<T>& operator-= ( const T &  h)
inline

◆ operator=()

List& operator= ( const List< T, E, A > &  list)
inline

◆ operator==()

bool operator== ( const List< T > &  l) const
inline

◆ operator[]() [1/2]

T& operator[] ( int  k)
inline

◆ operator[]() [2/2]

const T& operator[] ( int  k) const
inline

◆ pop()

T pop ( void  )
inline

◆ push()

void push ( const T &  i)
inline

◆ remove() [1/2]

void remove ( const T &  item)
inline

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 ListSet< T, C, A >::diff(), ListSet< T, C, A >::meet(), List< Pair< K, T >, CompareEquiv< AssocComparator< K, T, Comparator< K > > >, DefaultAlloc >::operator-=(), SortedList< Pair< string, Section * >, AssocComparator< string, Section *, Comparator< string > >, DefaultAlloc >::remove(), and List< Pair< K, T >, CompareEquiv< AssocComparator< K, T, Comparator< K > > >, DefaultAlloc >::removeAll().

◆ remove() [2/2]

◆ removeAll()

◆ removeFirst()

◆ removeLast()

void removeLast ( void  )
inline

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 SortedList< Pair< string, Section * >, AssocComparator< string, Section *, Comparator< string > >, DefaultAlloc >::removeLast().

◆ reset()

void reset ( void  )
inline

◆ set()

void set ( const Iter pos,
const T &  item 
)
inline

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.

Referenced by SortedList< Pair< string, Section * >, AssocComparator< string, Section *, Comparator< string > >, DefaultAlloc >::set().

◆ top()

const T& top ( void  ) const
inline

Member Data Documentation

◆ null

List< T, E, A > null
static

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