Open
Graph Drawing
Framework

 v.2012.07
 

ogdf::ListPure< E > Class Template Reference

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

#include <ogdf/basic/List.h>

+ Inheritance diagram for ogdf::ListPure< E >:

List of all members.

Public Types

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

Public Member Functions

 ListPure ()
 Constructs an empty doubly linked list.
 ListPure (const ListPure< E > &L)
 Constructs a doubly linked list that is a copy of L.
 ~ListPure ()
const E & back () const
 Returns a reference to the last element.
E & back ()
 Returns a reference to the last element.
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.
void bucketSort (int l, int h, BucketFunc< E > &f)
 Sorts the list using bucket sort.
const E chooseElement () const
 Returns a random element from the list.
chooseElement ()
 Returns a random element from the list.
ListConstIterator< E > chooseIterator () const
 Returns an iterator to a random element in the list (or an invalid iterator if the list is empty)
ListIterator< E > chooseIterator ()
 Returns an iterator to a random element in the list (or an invalid iterator if the list is empty)
void clear ()
 Removes all elements from the list.
void conc (ListPure< E > &L2)
 Appends L2 to this list and makes L2 empty.
void concFront (ListPure< E > &L2)
 Prepends L2 to this list and makes L2 empty.
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 > 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.
void del (ListIterator< E > it)
 Removes it from the list.
bool empty () const
 Returns true iff the list is empty.
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.
void exchange (ListIterator< E > it1, ListIterator< E > it2)
 Exchanges the positions of it1 and it2 in the list.
void exchange (ListPure< E > &L2)
 Exchanges too complete lists in O(1).
const E & front () const
 Returns a reference to the first element.
E & front ()
 Returns a reference to the first element.
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.
ListIterator< E > insert (const E &x, ListIterator< E > it, Direction dir=after)
 Inserts element x before or after it.
ListIterator< E > insertAfter (const E &x, ListIterator< E > it)
 Inserts element x after it.
ListIterator< E > insertBefore (const E &x, ListIterator< E > it)
 Inserts element x before it.
void moveToBack (ListIterator< E > it)
 Moves it to the end of the list.
void moveToBack (ListIterator< E > it, ListPure< E > &L2)
 Moves it to the end of L2.
void moveToFront (ListIterator< E > it)
 Moves it to the begin of the list.
void moveToFront (ListIterator< E > it, ListPure< E > &L2)
 Moves it to the begin of L2.
void moveToPrec (ListIterator< E > it, ListIterator< E > itAfter)
 Moves it before itAfter.
void moveToPrec (ListIterator< E > it, ListPure< E > &L2, ListIterator< E > itAfter)
 Moves it to list L2 and inserts it before itAfter.
void moveToSucc (ListIterator< E > it, ListIterator< E > itBefore)
 Moves it after itBefore.
void moveToSucc (ListIterator< E > it, ListPure< E > &L2, ListIterator< E > itBefore)
 Moves it to list L2 and inserts it after itBefore.
bool operator!= (const ListPure< E > &L) const
 Inequality operator.
ListPure< E > & operator= (const ListPure< E > &L)
 Assignment operator.
bool operator== (const ListPure< E > &L) const
 Equality operator.
void permute ()
 Randomly permutes the elements in the list.
void popBack ()
 Removes the last element from the list.
popBackRet ()
 Removes the last element from the list and returns it.
void popFront ()
 Removes the first element from the list.
popFrontRet ()
 Removes the first element from the list and returns it.
int pos (ListConstIterator< E > it) const
 Returns the position (starting with 0) of iterator it in the list.
ListIterator< E > pushBack (const E &x)
 Adds element x at the end of the list.
ListIterator< E > pushFront (const E &x)
 Adds element x at the begin of the list.
void quicksort ()
 Sorts the list using Quicksort.
template<class COMPARER >
void quicksort (const COMPARER &comp)
 Sorts the list using Quicksort and comparer comp.
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.
void reverse ()
 Reverses the order of the list elements.
int search (const E &e) const
 Scans the list for the specified element and returns its position in the list, or -1 if not found.
template<class COMPARER >
int search (const E &e, const COMPARER &comp) const
 Scans the list for the specified element (using the user-defined comparer) and returns its position in the list, or -1 if not found.
int size () const
 Returns the length of the list.
void split (ListIterator< E > it, ListPure< E > &L1, ListPure< E > &L2, Direction dir=before)
 Splits the list at element it into lists L1 and L2.
void splitAfter (ListIterator< E > it, ListPure< E > &L2)
 Splits the list after it.
void splitBefore (ListIterator< E > it, ListPure< E > &L2)
 Splits the list before it.

Protected Member Functions

void copy (const ListPure< E > &L)
void permute (const int n)

Protected Attributes

ListElement< E > * m_head
 Pointer to first element.
ListElement< E > * m_tail
 Pointer to last element.

Detailed Description

template<class E>
class ogdf::ListPure< 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 List<E>, instances of ListPure<E> do not store the length of the list.

Template Parameters:
Eis the data type stored in list elements.

Definition at line 274 of file List.h.


Member Typedef Documentation


Constructor & Destructor Documentation

template<class E>
ogdf::ListPure< E >::ListPure ( )
inline

Constructs an empty doubly linked list.

Definition at line 282 of file List.h.

template<class E>
ogdf::ListPure< E >::ListPure ( const ListPure< E > &  L)
inline

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

Definition at line 285 of file List.h.

template<class E>
ogdf::ListPure< E >::~ListPure ( )
inline

Definition at line 290 of file List.h.


Member Function Documentation

template<class E>
void ogdf::ListPure< E >::bucketSort ( int  l,
int  h,
BucketFunc< E > &  f 
)
template<class E>
void ogdf::ListPure< E >::conc ( ListPure< E > &  L2)
inline

Appends L2 to this list and makes L2 empty.

Definition at line 866 of file List.h.

template<class E>
void ogdf::ListPure< E >::concFront ( ListPure< E > &  L2)
inline

Prepends L2 to this list and makes L2 empty.

Definition at line 880 of file List.h.

template<class E>
void ogdf::ListPure< E >::copy ( const ListPure< E > &  L)
inlineprotected

Definition at line 1052 of file List.h.

template<class E>
void ogdf::ListPure< E >::exchange ( ListPure< E > &  L2)
inline

Exchanges too complete lists in O(1).

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

Definition at line 897 of file List.h.

template<class E>
ListIterator<E> ogdf::ListPure< E >::insert ( const E &  x,
ListIterator< E >  it,
Direction  dir = after 
)
inline
template<class E>
void ogdf::ListPure< E >::moveToBack ( ListIterator< E >  it,
ListPure< E > &  L2 
)
inline

Moves it to the end of L2.

Precondition:
it points to an element in this list.

Definition at line 804 of file List.h.

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

Moves it to the begin of L2.

Precondition:
it points to an element in this list.

Definition at line 783 of file List.h.

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

Moves it to list L2 and inserts it before itAfter.

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

Definition at line 848 of file List.h.

template<class E>
void ogdf::ListPure< E >::moveToSucc ( ListIterator< E >  it,
ListPure< 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 826 of file List.h.

template<class E>
bool ogdf::ListPure< E >::operator!= ( const ListPure< E > &  L) const
inline

Inequality operator.

Definition at line 520 of file List.h.

template<class E>
ListPure<E>& ogdf::ListPure< E >::operator= ( const ListPure< E > &  L)
inline

Assignment operator.

Definition at line 502 of file List.h.

template<class E>
bool ogdf::ListPure< E >::operator== ( const ListPure< E > &  L) const
inline

Equality operator.

Definition at line 508 of file List.h.

template<class E >
void ogdf::ListPure< E >::permute ( const int  n)
protected

Definition at line 1570 of file List.h.

template<class E>
void ogdf::ListPure< E >::split ( ListIterator< E >  it,
ListPure< E > &  L1,
ListPure< 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 917 of file List.h.

template<class E>
void ogdf::ListPure< E >::splitAfter ( ListIterator< E >  it,
ListPure< E > &  L2 
)
inline

Splits the list after it.

Definition at line 946 of file List.h.

template<class E>
void ogdf::ListPure< E >::splitBefore ( ListIterator< E >  it,
ListPure< E > &  L2 
)
inline

Splits the list before it.

Definition at line 960 of file List.h.


Member Data Documentation

template<class E>
ListElement<E>* ogdf::ListPure< E >::m_head
protected

Pointer to first element.

Definition at line 277 of file List.h.

template<class E>
ListElement<E>* ogdf::ListPure< E >::m_tail
protected

Pointer to last element.

Definition at line 278 of file List.h.


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