golib  0.5
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
goList< T > Class Template Reference

#include <golist.h>

Public Types

typedef goListElement< T > Element
 
typedef goListIterator< T > iterator
 
typedef goListConstIterator< T > const_iterator
 

Public Member Functions

 goList (const goList< T > &other)
 
 goList (const std::list< T > &l)
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
 operator std::list< T > ()
 
ElementgetFrontElement ()
 
ElementgetTailElement ()
 
ConstElement * getFrontElement () const
 
ConstElement * getTailElement () const
 
Elementfind (const T &e)
 
goSize_t findIndex (const T &e)
 
ConstElement * find (const T &e) const
 
goSize_t findIndex (const T &e) const
 
bool contains (const T &e) const
 
Elementoperator() (goSize_t i)
 Return element number i. More...
 
T & getItem (goSize_t i)
 
const T & getItem (goSize_t i) const
 
ConstElement * operator() (goSize_t i) const
 Return element number i. More...
 
void index ()
 Fill the index field of the list elements with indices starting at 0.
 
void next ()
 DEPRECATED.
 
void prev ()
 DEPRECATED.
 
T & getNext ()
 DEPRECATED.
 
T * getNextPtr ()
 DEPRECATED.
 
T & getPrev ()
 DEPRECATED.
 
T * getPrevPtr ()
 DEPRECATED.
 
T & getCurrent ()
 DEPRECATED.
 
T * getCurrentPtr ()
 DEPRECATED.
 
T & getFront ()
 Returns the front of the list.
 
const T & getFront () const
 
T * getFrontPtr ()
 
T & getTail ()
 Returns the tail of the list.
 
const T & getTail () const
 
T * getTailPtr ()
 
bool isFront () const
 
bool isTail () const
 
bool isEmpty () const
 
bool append (const T &elem)
 
bool prepend (const T &elem)
 
bool insert (const T &elem)
 
bool append (goListElement< T > *el, goListElement< T > *here)
 Append element after another element. More...
 
bool prepend (goListElement< T > *el, goListElement< T > *here)
 Prepend element before another element. More...
 
bool remove ()
 Removes the current Item.
 
goListElement< T > * remove (goListElement< T > *el)
 Erase an element from the list. More...
 
goListElement< T > * unhook (goListElement< T > *el)
 Unhook an element. More...
 
void erase ()
 Deletes the whole list leaving a zero length list.
 
void reverse ()
 
void close ()
 Makes a cyclic list by connecting front and tail.
 
void open (goListElement< T > *newFront)
 Opens a closed (cyclic) list and makes newFront the new front and the preceding element the new tail.
 
void open ()
 
bool isClosed () const
 
bool cyclicPermutation (goIndex_t count=1)
 
void resetToFront ()
 Resets the pointer to the front of the list.
 
goInt32 getSize () const
 
goList< T > & operator= (const goList< T > &other)
 Deep-copy this list. More...
 
goList< T > & operator= (const std::list< T > &other)
 
bool operator== (const goList< T > &other) const
 UNTESTED.
 
bool operator!= (const goList< T > &other) const
 UNTESTED.
 
bool operator< (goList< T > &other)
 
bool operator> (goList< T > &other)
 

Public Attributes

const typedef goListElement< T > ConstElement
 

Protected Attributes

goInt32 size
 
goListElement< T > * front
 
goListElement< T > * tail
 
goListElement< T > * position
 
goListElement< T > dummy
 

Detailed Description

template<class T>
class goList< T >

Simple doubly linked list. This list is not yet completely tested but should do so far.

Author
Christian Gosch

Member Function Documentation

◆ append()

template<class T>
bool goList< T >::append ( goListElement< T > *  el,
goListElement< T > *  here 
)
inline

Append element after another element.

Parameters
elElement to append
herePoint in list where to append el.
Returns
True if successful, false otherwise.

◆ end()

template<class T>
iterator goList< T >::end ( )
inline
Note
Returns the iterator pointing to NULL if the list is not closed. If it is closed, note that the tail element is returned, so in order to go through every element do the tail element at the end or use the getSize() method to determine the size and iterate over that number of elements. That should be preferred if you do not know if the list is closed or not.

◆ operator()() [1/2]

template<class T>
Element* goList< T >::operator() ( goSize_t  i)
inline

Return element number i.

Note
This is slow, O(this->getSize()). Lists are not meant for indexed access.
Returns
Element number i.

◆ operator()() [2/2]

template<class T>
ConstElement* goList< T >::operator() ( goSize_t  i) const
inline

Return element number i.

Note
This is slow, O(this->getSize()). Lists are not meant for indexed access.
Returns
Element number i.

◆ operator=()

template<class T>
goList< T > & goList< T >::operator= ( const goList< T > &  other)
inline

Deep-copy this list.

Makes a deep copy of this list, that is copied each element in other and appends it to this.

Parameters
otherlist to be copied.
Returns
Reference to *this.

Makes a deep copy of this list, that is copied each element in other and appends it to this.

Parameters
otherlist to be copied.

@return Reference to *this.

◆ prepend()

template<class T>
bool goList< T >::prepend ( goListElement< T > *  el,
goListElement< T > *  here 
)
inline

Prepend element before another element.

Parameters
elElement to prepend
herePoint in list where to prepend el.
Returns
True if successful, false otherwise.

◆ remove()

template<class T>
goListElement< T > * goList< T >::remove ( goListElement< T > *  el)
inline

Erase an element from the list.

Parameters
elThe element to remove.
Returns
The next element in the list (el->next).

◆ unhook()

template<class T>
goListElement< T > * goList< T >::unhook ( goListElement< T > *  el)
inline

Unhook an element.

The element is not deleted, as opposed to remove(). It can be re-inserted with the prepend and append methods or put into another list. However, if it is not re-inserted into a list, the user must make sure it gets deleted using the standard C++ delete operator.

Parameters
elElement to unhook.
Returns
The next element in the list after el, or 0.

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