Open
Graph Drawing
Framework

 v.2007.11
 

ogdf::List< E > Class Template Reference

The parameterized class ListPure<E> represents doubly linked lists with content type E. More...

#include <List.h>

Inheritance diagram for ogdf::List< E >:

ogdf::ListPure< E > ogdf::DPolyline ogdf::IPolyline ogdf::kList ogdf::RadialTreeLayout::Grouping ogdf::DPolygon

List of all members.

Public Types

typedef E value_type
typedef ListElement< E > element_type
typedef ListConstIterator< E > const_iterator
typedef ListIterator< E > iterator

Public Member Functions

 List ()
 Constructs an empty doubly linked list.
 List (const List< E > &L)
 Constructs a doubly linked list that is a copy of L.
 ~List ()
bool empty () const
 Returns true iff the list is empty.
int size () const
 Returns the length of the list.
const ListConstIterator< E > begin () const
 Returns an iterator to the first element of the list.
ListIterator< E > begin ()
 Returns an iterator to the first element of the list.
ListConstIterator< E > end () const
 Returns an iterator to one-past-last element of the list.
ListIterator< E > end ()
 Returns an iterator to one-past-last element of the list.
const ListConstIterator< E > rbegin () const
 Returns an iterator to the last element of the list.
ListIterator< E > rbegin ()
 Returns an iterator to the last element of the list.
ListConstIterator< E > rend () const
 Returns an iterator to one-before-first element of the list.
ListIterator< E > rend ()
 Returns an iterator to one-before-first element of the list.
const E & front () const
 Returns a reference to the first element.
E & front ()
 Returns a reference to the first element.
const E & back () const
 Returns a reference to the last element.
E & back ()
 Returns a reference to the last element.
ListConstIterator< E > cyclicSucc (ListConstIterator< E > it) const
 Returns an iterator to the cyclic successor of it.
ListIterator< E > cyclicSucc (ListIterator< E > it)
 Returns an iterator to the cyclic successor of it.
ListConstIterator< E > cyclicPred (ListConstIterator< E > it) const
 Returns an iterator to the cyclic predecessor of it.
ListIterator< E > cyclicPred (ListIterator< E > it)
 Returns an iterator to the cyclic predecessor of it.
ListConstIterator< E > get (int pos) const
 Returns an iterator pointing to the element at position pos.
ListIterator< E > get (int pos)
 Returns an iterator pointing to the element at position pos.
int pos (ListConstIterator< E > it) const
 Returns the position (starting with 0) of it in the list.
List< E > & operator= (const List< E > &L)
ListIterator< E > pushFront (const E &x)
 Adds element x at the begin of the list.
ListIterator< E > pushBack (const E &x)
 Adds element x at the end of the list.
ListIterator< E > insert (const E &x, ListIterator< E > it, Direction dir=after)
 Inserts element x before or after it.
ListIterator< E > insertBefore (const E &x, ListIterator< E > it)
 Inserts element x before it.
ListIterator< E > insertAfter (const E &x, ListIterator< E > it)
 Inserts element x after it.
void popFront ()
 Removes the first element from the list.
popFrontRet ()
 Removes the first element from the list and returns it.
void popBack ()
 Removes the last element from the list.
popBackRet ()
 Removes the last element from the list and returns it.
void exchange (ListIterator< E > it1, ListIterator< E > it2)
 Exchanges the positions of it1 and it2 in the list.
void moveToFront (ListIterator< E > it)
 Moves it to the beginning of the list.
void moveToBack (ListIterator< E > it)
 Moves it to the end of the list.
void moveToSucc (ListIterator< E > it, ListIterator< E > itBefore)
 Moves it after itBefore.
void moveToPrec (ListIterator< E > it, ListIterator< E > itAfter)
 Moves it before itAfter.
void moveToFront (ListIterator< E > it, List< E > &L2)
 Moves it to the beginning of L2.
void moveToBack (ListIterator< E > it, List< E > &L2)
 Moves it to the end of L2.
void moveToSucc (ListIterator< E > it, List< E > &L2, ListIterator< E > itBefore)
 Moves it to list L2 and inserts it after itBefore.
void moveToPrec (ListIterator< E > it, List< E > &L2, ListIterator< E > itAfter)
 Moves it to list L2 and inserts it after itBefore.
void del (ListIterator< E > it)
 Removes it from the list.
void conc (List< E > &L2)
 Appends L2 to this list and makes L2 empty.
void concFront (List< E > &L2)
 Prepends L2 to this list and makes L2 empty.
void exchange (List< E > &L2)
 Exchanges too complete lists in O(1).
void split (ListIterator< E > it, List< E > &L1, List< E > &L2, Direction dir=before)
 Splits the list at element it into lists L1 and L2.
void reverse ()
 Reverses the order of the list elements.
void clear ()
 Removes all elements from the list.
const ListPure< E > & getListPure () const
 Conversion to const SListPure.
void quicksort ()
 Sorts the list using Quicksort.
void quicksort (Comparer< E > &comp)
 Sorts the list using Quicksort and comparer comp.
template<class C>
void quicksortCT (C &comp)
 Sorts the list using Quicksort and parameterized comparer comp.
void bucketSort (int l, int h, BucketFunc< E > &f)
 Sorts the list using bucket sort.
void permute ()
 Randomly permutes the elements in the list.
int search (const E &e) const
int search (const E &e, Comparer< E > &comp) const
void * operator new (size_t nBytes)
void * operator new (size_t, void *p)
void operator delete (void *p, size_t nBytes)

Private Attributes

int m_count
 The length of the list.


Detailed Description

template<class E>
class ogdf::List< E >

The parameterized class ListPure<E> represents doubly linked lists with content type E.

Elements of the list are instances of type ListElement<E>. Use ListConstIterator<E> or ListIterator<E> in order to iterate over the list.

In contrast to ListPure<E>, instances of List<E> store the length of the list.

See the forall_listiterators macros for the recommended way how to easily iterate through a list. (Since this feature is rather new, you won't find many exampled in the code base yet.)

Definition at line 1082 of file List.h.


Member Typedef Documentation

template<class E>
typedef E ogdf::List< E >::value_type

Reimplemented from ogdf::ListPure< E >.

Definition at line 1096 of file List.h.

template<class E>
typedef ListElement<E> ogdf::List< E >::element_type

Reimplemented from ogdf::ListPure< E >.

Definition at line 1097 of file List.h.

template<class E>
typedef ListConstIterator<E> ogdf::List< E >::const_iterator

Reimplemented from ogdf::ListPure< E >.

Definition at line 1098 of file List.h.

template<class E>
typedef ListIterator<E> ogdf::List< E >::iterator

Reimplemented from ogdf::ListPure< E >.

Definition at line 1099 of file List.h.


Constructor & Destructor Documentation

template<class E>
ogdf::List< E >::List (  )  [inline]

Constructs an empty doubly linked list.

Definition at line 1088 of file List.h.

template<class E>
ogdf::List< E >::List ( const List< E > &  L  )  [inline]

Constructs a doubly linked list that is a copy of L.

Definition at line 1091 of file List.h.

template<class E>
ogdf::List< E >::~List (  )  [inline]

Definition at line 1094 of file List.h.


Member Function Documentation

template<class E>
bool ogdf::List< E >::empty (  )  const [inline]

Returns true iff the list is empty.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1102 of file List.h.

template<class E>
int ogdf::List< E >::size (  )  const [inline]

Returns the length of the list.

Notice that this method requires to run through the whole list and takes linear running time!

Reimplemented from ogdf::ListPure< E >.

Definition at line 1105 of file List.h.

template<class E>
const ListConstIterator<E> ogdf::List< E >::begin (  )  const [inline]

Returns an iterator to the first element of the list.

If the list is empty, a null pointer iterator is returned.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1108 of file List.h.

template<class E>
ListIterator<E> ogdf::List< E >::begin (  )  [inline]

Returns an iterator to the first element of the list.

If the list is empty, a null pointer iterator is returned.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1110 of file List.h.

template<class E>
ListConstIterator<E> ogdf::List< E >::end (  )  const [inline]

Returns an iterator to one-past-last element of the list.

This is always a null pointer iterator.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1113 of file List.h.

template<class E>
ListIterator<E> ogdf::List< E >::end (  )  [inline]

Returns an iterator to one-past-last element of the list.

This is always a null pointer iterator.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1115 of file List.h.

template<class E>
const ListConstIterator<E> ogdf::List< E >::rbegin (  )  const [inline]

Returns an iterator to the last element of the list.

If the list is empty, a null pointer iterator is returned.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1118 of file List.h.

template<class E>
ListIterator<E> ogdf::List< E >::rbegin (  )  [inline]

Returns an iterator to the last element of the list.

If the list is empty, a null pointer iterator is returned.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1120 of file List.h.

template<class E>
ListConstIterator<E> ogdf::List< E >::rend (  )  const [inline]

Returns an iterator to one-before-first element of the list.

This is always a null pointer iterator.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1123 of file List.h.

template<class E>
ListIterator<E> ogdf::List< E >::rend (  )  [inline]

Returns an iterator to one-before-first element of the list.

This is always a null pointer iterator.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1125 of file List.h.

template<class E>
const E& ogdf::List< E >::front (  )  const [inline]

Returns a reference to the first element.

Precondition:
The list is not empty!

Reimplemented from ogdf::ListPure< E >.

Definition at line 1128 of file List.h.

template<class E>
E& ogdf::List< E >::front (  )  [inline]

Returns a reference to the first element.

Precondition:
The list is not empty!

Reimplemented from ogdf::ListPure< E >.

Definition at line 1130 of file List.h.

template<class E>
const E& ogdf::List< E >::back (  )  const [inline]

Returns a reference to the last element.

Precondition:
The list is not empty!

Reimplemented from ogdf::ListPure< E >.

Definition at line 1133 of file List.h.

template<class E>
E& ogdf::List< E >::back (  )  [inline]

Returns a reference to the last element.

Precondition:
The list is not empty!

Reimplemented from ogdf::ListPure< E >.

Definition at line 1135 of file List.h.

template<class E>
ListConstIterator<E> ogdf::List< E >::cyclicSucc ( ListConstIterator< E >  it  )  const [inline]

Returns an iterator to the cyclic successor of it.

Precondition:
it points to an element in this list!

Reimplemented from ogdf::ListPure< E >.

Definition at line 1138 of file List.h.

template<class E>
ListIterator<E> ogdf::List< E >::cyclicSucc ( ListIterator< E >  it  )  [inline]

Returns an iterator to the cyclic successor of it.

Precondition:
it points to an element in this list!

Reimplemented from ogdf::ListPure< E >.

Definition at line 1143 of file List.h.

template<class E>
ListConstIterator<E> ogdf::List< E >::cyclicPred ( ListConstIterator< E >  it  )  const [inline]

Returns an iterator to the cyclic predecessor of it.

Precondition:
it points to an element in this list!

Reimplemented from ogdf::ListPure< E >.

Definition at line 1148 of file List.h.

template<class E>
ListIterator<E> ogdf::List< E >::cyclicPred ( ListIterator< E >  it  )  [inline]

Returns an iterator to the cyclic predecessor of it.

Precondition:
it points to an element in this list!

Reimplemented from ogdf::ListPure< E >.

Definition at line 1153 of file List.h.

template<class E>
ListConstIterator<E> ogdf::List< E >::get ( int  pos  )  const [inline]

Returns an iterator pointing to the element at position pos.

The running time of this method is linear in pos.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1158 of file List.h.

template<class E>
ListIterator<E> ogdf::List< E >::get ( int  pos  )  [inline]

Returns an iterator pointing to the element at position pos.

The running time of this method is linear in pos.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1164 of file List.h.

template<class E>
int ogdf::List< E >::pos ( ListConstIterator< E >  it  )  const [inline]

Returns the position (starting with 0) of it in the list.

Positions are numbered 0,1,...

Precondition:
it is an iterator pointing to an element in this list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1170 of file List.h.

template<class E>
List<E>& ogdf::List< E >::operator= ( const List< E > &  L  )  [inline]

Definition at line 1175 of file List.h.

template<class E>
ListIterator<E> ogdf::List< E >::pushFront ( const E &  x  )  [inline]

Adds element x at the begin of the list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1182 of file List.h.

template<class E>
ListIterator<E> ogdf::List< E >::pushBack ( const E &  x  )  [inline]

Adds element x at the end of the list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1188 of file List.h.

template<class E>
ListIterator<E> ogdf::List< E >::insert ( const E &  x,
ListIterator< E >  it,
Direction  dir = after 
) [inline]

Inserts element x before or after it.

Parameters:
x is the element to be inserted.
it is a list iterator in this list.
dir determines if x is inserted before or after it. Possible values are ogdf::before and ogdf::after.
Precondition:
it points to an element in this list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1194 of file List.h.

template<class E>
ListIterator<E> ogdf::List< E >::insertBefore ( const E &  x,
ListIterator< E >  it 
) [inline]

Inserts element x before it.

Precondition:
it points to an element in this list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1200 of file List.h.

template<class E>
ListIterator<E> ogdf::List< E >::insertAfter ( const E &  x,
ListIterator< E >  it 
) [inline]

Inserts element x after it.

Precondition:
it points to an element in this list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1206 of file List.h.

template<class E>
void ogdf::List< E >::popFront (  )  [inline]

Removes the first element from the list.

Precondition:
The list is not empty!

Reimplemented from ogdf::ListPure< E >.

Definition at line 1212 of file List.h.

template<class E>
E ogdf::List< E >::popFrontRet (  )  [inline]

Removes the first element from the list and returns it.

Precondition:
The list is not empty!

Reimplemented from ogdf::ListPure< E >.

Reimplemented in ogdf::kList.

Definition at line 1218 of file List.h.

template<class E>
void ogdf::List< E >::popBack (  )  [inline]

Removes the last element from the list.

Precondition:
The list is not empty!

Reimplemented from ogdf::ListPure< E >.

Definition at line 1225 of file List.h.

template<class E>
E ogdf::List< E >::popBackRet (  )  [inline]

Removes the last element from the list and returns it.

Precondition:
The list is not empty!

Reimplemented from ogdf::ListPure< E >.

Definition at line 1231 of file List.h.

template<class E>
void ogdf::List< E >::exchange ( ListIterator< E >  it1,
ListIterator< E >  it2 
) [inline]

Exchanges the positions of it1 and it2 in the list.

Precondition:
it1 and it2 point to elements in this list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1237 of file List.h.

template<class E>
void ogdf::List< E >::moveToFront ( ListIterator< E >  it  )  [inline]

Moves it to the beginning of the list.

Precondition:
it points to an element in the list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1245 of file List.h.

template<class E>
void ogdf::List< E >::moveToBack ( ListIterator< E >  it  )  [inline]

Moves it to the end of the list.

Precondition:
it points to an element in the list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1252 of file List.h.

template<class E>
void ogdf::List< E >::moveToSucc ( ListIterator< E >  it,
ListIterator< E >  itBefore 
) [inline]

Moves it after itBefore.

Precondition:
it and itBefore point to elements in this list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1259 of file List.h.

template<class E>
void ogdf::List< E >::moveToPrec ( ListIterator< E >  it,
ListIterator< E >  itAfter 
) [inline]

Moves it before itAfter.

Precondition:
it and itAfter point to elements in this list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1266 of file List.h.

template<class E>
void ogdf::List< E >::moveToFront ( ListIterator< E >  it,
List< E > &  L2 
) [inline]

Moves it to the beginning of L2.

Precondition:
it points to an element in this list.

Definition at line 1274 of file List.h.

template<class E>
void ogdf::List< E >::moveToBack ( ListIterator< E >  it,
List< E > &  L2 
) [inline]

Moves it to the end of L2.

Precondition:
it points to an element in this list.

Definition at line 1282 of file List.h.

template<class E>
void ogdf::List< E >::moveToSucc ( ListIterator< E >  it,
List< E > &  L2,
ListIterator< E >  itBefore 
) [inline]

Moves it to list L2 and inserts it after itBefore.

Precondition:
it points to an element in this list, and itBefore points to an element in L2.

Definition at line 1292 of file List.h.

template<class E>
void ogdf::List< E >::moveToPrec ( ListIterator< E >  it,
List< E > &  L2,
ListIterator< E >  itAfter 
) [inline]

Moves it to list L2 and inserts it after itBefore.

Precondition:
it points to an element in this list, and itBefore points to an element in L2.

Definition at line 1301 of file List.h.

template<class E>
void ogdf::List< E >::del ( ListIterator< E >  it  )  [inline]

Removes it from the list.

Precondition:
it points to an element in this list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1307 of file List.h.

template<class E>
void ogdf::List< E >::conc ( List< E > &  L2  )  [inline]

Appends L2 to this list and makes L2 empty.

Definition at line 1320 of file List.h.

template<class E>
void ogdf::List< E >::concFront ( List< E > &  L2  )  [inline]

Prepends L2 to this list and makes L2 empty.

Definition at line 1327 of file List.h.

template<class E>
void ogdf::List< E >::exchange ( List< E > &  L2  )  [inline]

Exchanges too complete lists in O(1).

The list's content is moved to L2 and vice versa.

Definition at line 1337 of file List.h.

template<class E>
void ogdf::List< E >::split ( ListIterator< E >  it,
List< E > &  L1,
List< E > &  L2,
Direction  dir = before 
) [inline]

Splits the list at element it into lists L1 and L2.

If it is not a null pointer and L = x1,...,x{k-1}, it,x_{k+1},xn, then L1 = x1,...,x{k-1} and L2 = it,x{k+1},...,xn if dir = before. If it is a null pointer, then L1 is made empty and L2 = L. Finally L is made empty if it is not identical to L1 or L2.

Precondition:
it points to an element in this list.

Definition at line 1353 of file List.h.

template<class E>
void ogdf::List< E >::reverse (  )  [inline]

Reverses the order of the list elements.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1365 of file List.h.

template<class E>
void ogdf::List< E >::clear (  )  [inline]

Removes all elements from the list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1368 of file List.h.

template<class E>
const ListPure<E>& ogdf::List< E >::getListPure (  )  const [inline]

Conversion to const SListPure.

Definition at line 1374 of file List.h.

template<class E>
void ogdf::List< E >::quicksort (  )  [inline]

Sorts the list using Quicksort.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1377 of file List.h.

template<class E>
void ogdf::List< E >::quicksort ( Comparer< E > &  comp  )  [inline]

Sorts the list using Quicksort and comparer comp.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1382 of file List.h.

template<class E>
template<class C>
void ogdf::List< E >::quicksortCT ( C &  comp  )  [inline]

Sorts the list using Quicksort and parameterized comparer comp.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1388 of file List.h.

template<class E>
void ogdf::List< E >::bucketSort ( int  l,
int  h,
BucketFunc< E > &  f 
) [inline]

Sorts the list using bucket sort.

Parameters:
l is the lowest bucket that will occur.
h is the highest bucket that will occur.
f returns the bucket for each element.
Precondition:
The bucket function f will only return bucket values between l and h for this list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1406 of file List.h.

template<class E>
void ogdf::List< E >::permute (  )  [inline]

Randomly permutes the elements in the list.

Reimplemented from ogdf::ListPure< E >.

Definition at line 1411 of file List.h.

template<class E>
int ogdf::List< E >::search ( const E &  e  )  const [inline]

Reimplemented from ogdf::ListPure< E >.

Definition at line 1415 of file List.h.

template<class E>
int ogdf::List< E >::search ( const E &  e,
Comparer< E > &  comp 
) const [inline]

Reimplemented from ogdf::ListPure< E >.

Definition at line 1418 of file List.h.

template<class E>
void* ogdf::List< E >::operator new ( size_t  nBytes  )  [inline]

Reimplemented from ogdf::ListPure< E >.

Definition at line 1423 of file List.h.

template<class E>
void* ogdf::List< E >::operator new ( size_t  ,
void *  p 
) [inline]

Reimplemented from ogdf::ListPure< E >.

Definition at line 1423 of file List.h.

template<class E>
void ogdf::List< E >::operator delete ( void *  p,
size_t  nBytes 
) [inline]

Reimplemented from ogdf::ListPure< E >.

Definition at line 1423 of file List.h.


Member Data Documentation

template<class E>
int ogdf::List< E >::m_count [private]

The length of the list.

Definition at line 1084 of file List.h.


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

© 1999-2007 by oreas GmbH, © 2005-2007 by University Dortmund and University Cologne.

Generated on Thu Nov 22 19:40:08 2007 by doxygen 1.5.4.