Public Member Functions | Private Member Functions | List of all members
QList< type > Class Template Reference

#include <qlist.h>

Inheritance diagram for QList< type >:
QGList QSortedList< type >

Public Member Functions

 QList ()
 
 QList (const QList< type > &l)
 
 ~QList ()
 
QList< type > & operator= (const QList< type > &l)
 
bool operator== (const QList< type > &list) const
 
uint count () const
 
bool isEmpty () const
 
bool insert (uint i, const type *d)
 
void inSort (const type *d)
 
void prepend (const type *d)
 
void append (const type *d)
 
bool remove (uint i)
 
bool remove (const type *d)
 
bool removeRef (const type *d)
 
bool removeFirst ()
 
bool removeLast ()
 
typetake (uint i)
 
void clear ()
 
void sort ()
 
int find (const type *d) const
 
int findRef (const type *d) const
 
uint contains (const type *d) const
 
uint containsRef (const type *d) const
 
typeat (uint i) const
 
typegetFirst () const
 
typegetLast () const
 
void setAutoDelete (bool enable)
 

Private Member Functions

virtual int compareValues (const type *t1, const type *t2) const
 
virtual typenewValue (type *item) const
 
virtual void deleteValue (type *item) const
 
virtual Item newItem (Item item)
 
virtual void deleteItem (QCollection::Item item)
 
virtual int compareItems (QCollection::Item i1, QCollection::Item i2)
 
- Private Member Functions inherited from QGList
QDataStreamread (QDataStream &)
 
QDataStreamwrite (QDataStream &) const
 
 QGList ()
 
 QGList (const QGList &)
 
virtual ~QGList ()
 
QGListoperator= (const QGList &)
 
bool operator== (const QGList &) const
 
void inSort (QCollection::Item)
 
void append (QCollection::Item)
 
bool insertAt (uint index, QCollection::Item)
 
void relinkNode (QLNode *)
 
bool removeNode (QLNode *)
 
bool remove (QCollection::Item=0)
 
bool removeRef (QCollection::Item=0)
 
bool removeFirst ()
 
bool removeLast ()
 
bool removeAt (uint index)
 
QCollection::Item takeNode (QLNode *)
 
QCollection::Item take ()
 
QCollection::Item takeAt (uint index)
 
QCollection::Item takeFirst ()
 
QCollection::Item takeLast ()
 
void sort ()
 
int findRef (QCollection::Item, bool=TRUE)
 
int find (QCollection::Item, bool=TRUE)
 
uint containsRef (QCollection::Item) const
 
uint contains (QCollection::Item) const
 
QCollection::Item at (uint index)
 
int at () const
 
QLNodecurrentNode () const
 
QCollection::Item get () const
 
QCollection::Item cfirst () const
 
QCollection::Item clast () const
 
QCollection::Item first ()
 
QCollection::Item last ()
 
QCollection::Item next ()
 
QCollection::Item prev ()
 
void toVector (QGVector *) const
 
virtual QDataStreamread (QDataStream &, QCollection::Item &)
 
virtual QDataStreamwrite (QDataStream &, QCollection::Item) const
 
- Private Member Functions inherited from QCollection
bool autoDelete () const
 
void setAutoDelete (bool enable)
 
 QCollection ()
 
 QCollection (const QCollection &)
 
virtual ~QCollection ()
 

Additional Inherited Members

- Private Types inherited from QCollection
typedef void * Item
 
- Private Attributes inherited from QCollection
bool del_item
 

Detailed Description

template<class type>
class QList< type >

Definition at line 54 of file qlist.h.

Constructor & Destructor Documentation

template<class type>
QList< type >::QList ( )
inline

Definition at line 57 of file qlist.h.

57 {}
template<class type>
QList< type >::QList ( const QList< type > &  l)
inline

Definition at line 58 of file qlist.h.

58 : QGList(l) {}
QGList()
Definition: qglist.cpp:170
template<class type>
QList< type >::~QList ( )
inline

Definition at line 59 of file qlist.h.

59 { clear(); }
void clear()
Definition: qlist.h:82

Member Function Documentation

template<class type>
void QList< type >::append ( const type d)
inline

Definition at line 73 of file qlist.h.

void append(QCollection::Item)
Definition: qglist.cpp:364
void * Item
Definition: qcollection.h:60
template<class type>
type* QList< type >::at ( uint  i) const
inline

Definition at line 94 of file qlist.h.

94 { return (type *)const_cast<QList<type>*>(this)->QGList::at(i); }
int at() const
Definition: qglist.h:167
Definition: qlist.h:54
template<class type>
void QList< type >::clear ( )
inlinevirtual

Removes all objects from the collection. The objects will be deleted if auto-delete has been enabled.

See also
setAutoDelete()

Reimplemented from QGList.

Definition at line 82 of file qlist.h.

82 { QGList::clear(); }
void clear()
Definition: qglist.cpp:652
template<class type>
virtual int QList< type >::compareItems ( QCollection::Item  item1,
QCollection::Item  item2 
)
inlineprivatevirtual

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:

Reimplemented from QGList.

Reimplemented in QSortedList< type >.

Definition at line 115 of file qlist.h.

116  { return compareValues((const type*)i1,(const type*)i2); }
virtual int compareValues(const type *t1, const type *t2) const
Definition: qlist.h:103
template<class type>
virtual int QList< type >::compareValues ( const type t1,
const type t2 
) const
inlineprivatevirtual
template<class type>
uint QList< type >::contains ( const type d) const
inline

Definition at line 90 of file qlist.h.

90 { return QGList::contains((QCollection::Item)d); }
uint contains(QCollection::Item) const
Definition: qglist.cpp:751
void * Item
Definition: qcollection.h:60
template<class type>
uint QList< type >::containsRef ( const type d) const
inline

Definition at line 91 of file qlist.h.

uint containsRef(QCollection::Item) const
Definition: qglist.cpp:734
void * Item
Definition: qcollection.h:60
template<class type>
uint QList< type >::count ( ) const
inlinevirtual

Returns the number of objects in the collection.

Reimplemented from QGList.

Definition at line 66 of file qlist.h.

66 { return QGList::count(); }
uint count() const
Definition: qglist.h:150
template<class type>
virtual void QList< type >::deleteItem ( QCollection::Item  d)
inlineprivatevirtual

Virtual function that deletes an item that is about to be removed from the collection.

The default implementation deletes d pointer if and only if auto-delete has been enabled.

This function is always reimplemented in the collection template classes.

Warning
If you reimplement this function you must also reimplement the destructor and call the virtual function clear() from your destructor. This is due to the way virtual functions and destructors work in C++: virtual functions in derived classes cannot be called from a destructor. If you do not do this your deleteItem() function will not be called when the container is destructed.
See also
newItem(), setAutoDelete()

Reimplemented from QCollection.

Definition at line 113 of file qlist.h.

114  { deleteValue((type *)item); }
virtual void deleteValue(type *item) const
Definition: qlist.h:107
template<class type>
virtual void QList< type >::deleteValue ( type item) const
inlineprivatevirtual

Reimplemented in HtmlAttribList.

Definition at line 107 of file qlist.h.

108  { if (del_item) delete item; }
bool del_item
Definition: qcollection.h:67
template<class type>
int QList< type >::find ( const type d) const
inline

Definition at line 88 of file qlist.h.

88 { return const_cast<QList<type>*>(this)->QGList::find((QCollection::Item)d); }
Definition: qlist.h:54
void * Item
Definition: qcollection.h:60
int find(QCollection::Item, bool=TRUE)
Definition: qglist.cpp:708
template<class type>
int QList< type >::findRef ( const type d) const
inline

Definition at line 89 of file qlist.h.

89 { return const_cast<QList<type>*>(this)->QGList::findRef((QCollection::Item)d); }
int findRef(QCollection::Item, bool=TRUE)
Definition: qglist.cpp:683
Definition: qlist.h:54
void * Item
Definition: qcollection.h:60
template<class type>
type* QList< type >::getFirst ( ) const
inline

Definition at line 95 of file qlist.h.

95 { return (type *)QGList::cfirst(); }
QCollection::Item cfirst() const
Definition: qglist.h:188
template<class type>
type* QList< type >::getLast ( ) const
inline

Definition at line 96 of file qlist.h.

96 { return (type *)QGList::clast(); }
QCollection::Item clast() const
Definition: qglist.h:193
template<class type>
bool QList< type >::insert ( uint  i,
const type d 
)
inline

Definition at line 70 of file qlist.h.

70 { return QGList::insertAt(i,(QCollection::Item)d); }
bool insertAt(uint index, QCollection::Item)
Definition: qglist.cpp:384
void * Item
Definition: qcollection.h:60
template<class type>
void QList< type >::inSort ( const type d)
inline

Definition at line 71 of file qlist.h.

void inSort(QCollection::Item)
Definition: qglist.cpp:327
void * Item
Definition: qcollection.h:60
template<class type>
bool QList< type >::isEmpty ( ) const
inline

Definition at line 67 of file qlist.h.

67 { return QGList::count() == 0; }
uint count() const
Definition: qglist.h:150
template<class type>
virtual Item QList< type >::newItem ( Item  d)
inlineprivatevirtual

Virtual function that creates a copy of an object that is about to be inserted into the collection.

The default implementation returns the d pointer, i.e. no copy is made.

This function is seldom reimplemented in the collection template classes. It is not common practice to make a copy of something that is being inserted.

See also
deleteItem()

Reimplemented from QCollection.

Definition at line 111 of file qlist.h.

112  { return (Item)newValue((type*)item); }
virtual type * newValue(type *item) const
Definition: qlist.h:105
void * Item
Definition: qcollection.h:60
template<class type>
virtual type* QList< type >::newValue ( type item) const
inlineprivatevirtual

Reimplemented in HtmlAttribList.

Definition at line 105 of file qlist.h.

106  { return item; }
template<class type>
QList<type>& QList< type >::operator= ( const QList< type > &  l)
inline

Definition at line 60 of file qlist.h.

61  { return (QList<type>&)QGList::operator=(l); }
QGList & operator=(const QGList &)
Definition: qglist.cpp:222
Definition: qlist.h:54
template<class type>
bool QList< type >::operator== ( const QList< type > &  list) const
inline

Definition at line 62 of file qlist.h.

63  { return QGList::operator==( list ); }
bool operator==(const QGList &) const
Definition: qglist.cpp:242
template<class type>
void QList< type >::prepend ( const type d)
inline

Definition at line 72 of file qlist.h.

bool insertAt(uint index, QCollection::Item)
Definition: qglist.cpp:384
void * Item
Definition: qcollection.h:60
template<class type>
bool QList< type >::remove ( uint  i)
inline

Definition at line 76 of file qlist.h.

76 { return QGList::removeAt(i); }
bool removeAt(uint index)
Definition: qglist.cpp:554
template<class type>
bool QList< type >::remove ( const type d)
inline

Definition at line 77 of file qlist.h.

77 { return QGList::remove((QCollection::Item)d); }
bool remove(QCollection::Item=0)
Definition: qglist.cpp:504
void * Item
Definition: qcollection.h:60
template<class type>
bool QList< type >::removeFirst ( )
inline

Definition at line 79 of file qlist.h.

79 { return QGList::removeFirst(); }
bool removeFirst()
Definition: qglist.h:155
template<class type>
bool QList< type >::removeLast ( )
inline

Definition at line 80 of file qlist.h.

80 { return QGList::removeLast(); }
bool removeLast()
Definition: qglist.h:161
template<class type>
bool QList< type >::removeRef ( const type d)
inline

Definition at line 78 of file qlist.h.

bool removeRef(QCollection::Item=0)
Definition: qglist.cpp:523
void * Item
Definition: qcollection.h:60
template<class type>
void QList< type >::setAutoDelete ( bool  enable)
inline

Definition at line 99 of file qlist.h.

99 { QGList::setAutoDelete(enable); }
void setAutoDelete(bool enable)
Definition: qcollection.h:55
template<class type>
void QList< type >::sort ( )
inline

Definition at line 85 of file qlist.h.

85 { QGList::sort(); }
void sort()
Definition: qglist.cpp:934
template<class type>
type* QList< type >::take ( uint  i)
inline

Definition at line 81 of file qlist.h.

81 { return (type *)QGList::takeAt(i); }
QCollection::Item takeAt(uint index)
Definition: qglist.cpp:608

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