---
name: "qglist"
section: "3qt"
platform: "linux"
package: "qt-doc"
version: "3:2.3.1-22"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/qglist"
---

# qglist(3qt)

Internal class for implementing Qt collection classes #include \<qglist.h\> Inherits QCollection. Inherited by QList, QQueue and QStack.

## NAME

QGList - Internal class for implementing Qt collection classes\

`#include <qglist.h>`

Inherits QCollection.

Inherited by QList, QQueue and QStack.

### Public Members

**virtual uint count () const (internal)**\
 **QDataStream& read ( QDataStream & ) (internal)**\
 **QDataStream& write ( QDataStream & ) const (internal)**\

### Protected Members

**QGList () (internal)**\
 **QGList ( const QGList & ) (internal)**\
 **virtual ~QGList () (internal)**\
 **QGList& operator= ( const QGList & ) (internal)**\
 **bool operator== ( const QGList & ) const**\
 **void inSort ( QCollection::Item ) (internal)**\
 **void append ( QCollection::Item ) (internal)**\
 **bool insertAt ( uint** *index***, QCollection::Item ) (internal)**\
 **void relinkNode ( QLNode \* ) (internal)**\
 **bool removeNode ( QLNode \* ) (internal)**\
 **bool remove ( QCollection::Item = 0 ) (internal)**\
 **bool removeRef ( QCollection::Item = 0 ) (internal)**\
 **bool removeFirst () (internal)**\
 **bool removeLast () (internal)**\
 **bool removeAt ( uint index ) (internal)**\
 **QCollection::Item takeNode ( QLNode \* ) (internal)**\
 **QCollection::Item take () (internal)**\
 **QCollection::Item takeAt ( uint index ) (internal)**\
 **QCollection::Item takeFirst () (internal)**\
 **QCollection::Item takeLast () (internal)**\
 **void sort ()** \
 **virtual void clear () (internal)**\
 **int findRef ( QCollection::Item, bool = TRUE ) (internal)**\
 **int find ( QCollection::Item, bool = TRUE ) (internal)**\
 **uint containsRef ( QCollection::Item ) const (internal)**\
 **uint contains ( QCollection::Item ) const (internal)**\
 **QCollection::Item at ( uint index ) (internal)**\
 **int at () const (internal)**\
 **QLNode\* currentNode () const (internal)**\
 **QCollection::Item get () const (internal)**\
 **QCollection::Item cfirst () const (internal)**\
 **QCollection::Item clast () const (internal)**\
 **QCollection::Item first () (internal)**\
 **QCollection::Item last () (internal)**\
 **QCollection::Item next () (internal)**\
 **QCollection::Item prev () (internal)**\
 **void toVector ( QGVector \* ) const (internal)**\
 **virtual int compareItems ( QCollection::Item, QCollection::Item )** \
 **virtual QDataStream& read ( QDataStream &, QCollection::Item & )** \
 **virtual QDataStream& write ( QDataStream &, QCollection::Item ) const**\

## DESCRIPTION

The QGList class is an internal class for implementing Qt collection classes.

QGList is a strictly internal class that acts as a base class for several collection classes; QList, QQueue and QStack.

QGList has some virtual functions that can be reimplemented to customize the subclasses.

- compareItems() compares two collection/list items.

  - read() reads a collection/list item from a QDataStream.

  - write() writes a collection/list item to a QDataStream. Normally, you do not have to reimplement any of these functions. If you still want to reimplement them, see the QStrList class (qstrlist.h), which is a good example.

  ## MEMBER FUNCTION DOCUMENTATION

## int QGList::compareItems ( QCollection::Item item1, QCollection::Item item2 ) `[virtual protected]`

This virtual function compares two list items.

Returns:

- 0 if *item1* == *item2*

  - non-zero if *item1* != *item2*

  This function returns *int* rather than *bool* so that reimplementations can return three values and use it to sort by:

- 0 if *item1* == *item2*

  - \> 0 (positive integer) if *item1* \> *item2*

  - \< 0 (negative integer) if *item1* \< *item2*

  The QList::inSort() function requires that compareItems() is implemented as described here.

This function should not modify the list because some const functions call compareItems().

The default implementation compares the pointers:

```

```

## bool QGList::operator== ( const QGList & list ) const `[protected]`

Compares this list with *list.* Retruns TRUE if the lists contain the same data, else FALSE.

## QDataStream & QGList::read ( QDataStream & s, QCollection::Item & item ) `[virtual protected]`

Reads a collection/list item from the stream *s* and returns a reference to the stream.

The default implementation sets *item* to 0.

See also write().

## void QGList::sort () `[protected]`

Sorts the list by the result of the virtual compareItems() function.

The Heap-Sort algorithm is used for sorting. It sorts n items with O(n\*log n) compares. This is the asymptotic optimal solution of the sorting problem.

## QDataStream & QGList::write ( QDataStream & s, QCollection::Item ) const `[virtual protected]`

Writes a collection/list item to the stream *s* and returns a reference to the stream.

The default implementation does nothing.

See also read().

## QGList::QGList () `[protected]`

For internal use only.

## QGList::QGList ( const QGList & list ) `[protected]`

For internal use only.

## QGList::~QGList () `[virtual protected]`

For internal use only.

## void QGList::append ( QCollection::Item d ) `[protected]`

For internal use only.

## QCollection::Item QGList::at( uint index ) `[protected]`

For internal use only.

## int QGList::at () const `[protected]`

For internal use only.

## QCollection::Item QGList::cfirst() const `[protected]`

For internal use only.

## QCollection::Item QGList::clast() const `[protected]`

For internal use only.

## void QGList::clear () `[virtual protected]`

For internal use only.

Reimplemented from QCollection.

## uint QGList::contains ( QCollection::Item d ) const `[protected]`

For internal use only.

## uint QGList::containsRef ( QCollection::Item d ) const `[protected]`

For internal use only.

## uint QGList::count () const `[virtual]`

For internal use only.

Reimplemented from QCollection.

## QLNode \* QGList::currentNode () const `[protected]`

For internal use only.

## int QGList::find ( QCollection::Item d, bool fromStart = TRUE ) `[protected]`

For internal use only.

## int QGList::findRef ( QCollection::Item d, bool fromStart = TRUE ) `[protected]`

For internal use only.

## QCollection::Item QGList::first() `[protected]`

For internal use only.

## QCollection::Item QGList::get() const `[protected]`

For internal use only.

## void QGList::inSort ( QCollection::Item d ) `[protected]`

For internal use only.

## bool QGList::insertAt ( uint index, QCollection::Item d ) `[protected]`

For internal use only.

## QCollection::Item QGList::last() `[protected]`

For internal use only.

## QCollection::Item QGList::next() `[protected]`

For internal use only.

## QGList& QGList::operator= ( const QGList & list ) `[protected]`

For internal use only.

## QCollection::Item QGList::prev() `[protected]`

For internal use only.

## QDataStream & QGList::read ( QDataStream & s )

For internal use only.

## void QGList::relinkNode ( QLNode \* n ) `[protected]`

For internal use only.

## bool QGList::remove ( QCollection::Item d = 0 ) `[protected]`

For internal use only.

## bool QGList::removeAt ( uint index ) `[protected]`

For internal use only.

## bool QGList::removeFirst () `[protected]`

For internal use only.

## bool QGList::removeLast () `[protected]`

For internal use only.

## bool QGList::removeNode ( QLNode \* n ) `[protected]`

For internal use only.

## bool QGList::removeRef ( QCollection::Item d = 0 ) `[protected]`

For internal use only.

## QCollection::Item QGList::take() `[protected]`

For internal use only.

## QCollection::Item QGList::takeAt( uint index ) `[protected]`

For internal use only.

## QCollection::Item QGList::takeFirst() `[protected]`

For internal use only.

## QCollection::Item QGList::takeLast() `[protected]`

For internal use only.

## QCollection::Item QGList::takeNode( QLNode \* n ) `[protected]`

For internal use only.

## void QGList::toVector ( QGVector \* vector ) const `[protected]`

For internal use only.

## QDataStream & QGList::write ( QDataStream & s ) const

For internal use only.

## SEE ALSO

**http://doc.trolltech.com/qglist.html** **http://www.trolltech.com/faq/tech.html**

## COPYRIGHT

Copyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See the license file included in the distribution for a complete license statement.

## AUTHOR

Generated automatically from the source code.

## BUGS

If you find a bug in Qt, please report it as described in **http://doc.trolltech.com/bughowto.html**. Good bug reports make our job much simpler. Thank you.

In case of content or formattting problems with this manual page, please report them to **qt-bugs@trolltech.com**. Please include the name of the manual page (qglist.3qt) and the Qt version (2.3.1).
