template<class TYPE, class TI> class GListTemplate: protected GListImpl<TI>

Common base class for all doubly linked lists.

Inheritance:


Public Fields

[more] Inserts an element after the last element of the list.

Public Methods

[more]int size() const
Returns the number of elements in the list.
[more]GPosition firstpos() const
Returns the first position in the list.
[more]GPosition lastpos() const
Returns the last position in the list.
[more] operator GPosition() const
Implicit notation for GList::firstpos().
[more]TYPE& operator[](GPosition pos)
Returns a reference to the list element at position pos.
[more]const TYPE& operator[](GPosition pos) const
Returns a constant reference to the list element at position pos.
[more]int isempty() const
Tests whether a list is empty.
[more]int operator==(const GListTemplate<TYPE, TI> &l2) const
Compares two lists.
[more]GPosition nth(unsigned int n) const
Returns the position pos of the n-th list element.
[more]GPosition contains(const TYPE &elt) const
Tests whether the list contains a given element.
[more]int search(const TYPE &elt, GPosition &pos) const
Searches the list for a given element.
[more]void empty()
Erases the list contents.


Documentation

Common base class for all doubly linked lists. Class GListTemplate implements all methods for manipulating lists of of objects of type TYPE. You should not however create instances of this class. You should instead use class GList or GPList.
oint size() const
Returns the number of elements in the list.

oGPosition firstpos() const
Returns the first position in the list. See GPosition.

oGPosition lastpos() const
Returns the last position in the list. See GPosition.

o operator GPosition() const
Implicit notation for GList::firstpos().

oTYPE& operator[](GPosition pos)
Returns a reference to the list element at position pos. This reference can be used for both reading (as "a[n]") and modifying (as "a[n]=v") a list element. Using an invalid position will cause a segmentation violation. See GPosition for efficient operations on positions.

oconst TYPE& operator[](GPosition pos) const
Returns a constant reference to the list element at position pos. This reference only be used for reading a list element. An exception GException is thrown if pos is not a valid position. This variant of operator[] is necessary when dealing with a constGList<TYPE>. See \Ref{GPosition} for efficient operations onpositions.

oint isempty() const
Tests whether a list is empty. Returns a non zero value if the list contains no elements.

oint operator==(const GListTemplate<TYPE, TI> &l2) const
Compares two lists. Returns a non zero value if and only if both lists contain the same elements (as tested by TYPE::operator==(const TYPE&) in the same order.

oGPosition nth(unsigned int n) const
Returns the position pos of the n-th list element. An invalid position is returned if the list contains less than n elements. The operation works by sequentially scanning the list until reaching the n-th element.

oGPosition contains(const TYPE &elt) const
Tests whether the list contains a given element. If the list contains

checked by TYPE::operator==(const TYPE&) is returned. Otherwise an invalid position is returned.

oint search(const TYPE &elt, GPosition &pos) const
Searches the list for a given element. If position pos is a valid position for this list, the search starts at the specified position. If position pos is not a valid position, the search starts at the beginning of the list. The list elements are sequentially compared with

is equal to position of this list element and returns 1. If however the search reaches the end of the list, function search returns 0 and leaves pos unchanged.

ovoid empty()
Erases the list contents. All list elements are destroyed and unlinked. The list is left with zero elements.

o Inserts an element after the last element of the list.
Inserts an element after the last element of the list. The new element is initialized with a copy of argument void append(const TYPE &elt) { GListImpl<TI>::append(newnode((const TI&)elt)); } ;


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java


DjVu is a trademark of LizardTech, Inc.
All other products mentioned are registered trademarks or trademarks of their respective companies.