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

#include <qstack.h>

Inheritance diagram for QStack< type >:
QGList

Public Member Functions

 QStack ()
 
 QStack (const QStack< type > &s)
 
 ~QStack ()
 
QStack< type > & operator= (const QStack< type > &s)
 
bool autoDelete () const
 
void setAutoDelete (bool del)
 
uint count () const
 
bool isEmpty () const
 
void push (const type *d)
 
typepop ()
 
bool remove ()
 
void clear ()
 
typebottom () const
 
typetop () const
 
 operator type * () const
 
typecurrent () const
 

Private Member Functions

void deleteItem (Item d)
 
- 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 int compareItems (QCollection::Item, QCollection::Item)
 
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 ()
 
virtual Item newItem (Item)
 

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 QStack< type >

Definition at line 46 of file qstack.h.

Constructor & Destructor Documentation

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

Definition at line 49 of file qstack.h.

49 {}
template<class type>
QStack< type >::QStack ( const QStack< type > &  s)
inline

Definition at line 50 of file qstack.h.

50 : QGList(s) {}
QGList()
Definition: qglist.cpp:170
template<class type>
QStack< type >::~QStack ( )
inline

Definition at line 51 of file qstack.h.

51 { clear(); }
void clear()
Definition: qstack.h:61

Member Function Documentation

template<class type>
bool QStack< type >::autoDelete ( ) const
inline

Definition at line 54 of file qstack.h.

54 { return QCollection::autoDelete(); }
bool autoDelete() const
Definition: qcollection.h:54
template<class type>
type* QStack< type >::bottom ( ) const
inline

Definition at line 62 of file qstack.h.

62 { return (type *)QGList::clast(); }
QCollection::Item clast() const
Definition: qglist.h:193
template<class type>
void QStack< 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 61 of file qstack.h.

61 { QGList::clear(); }
void clear()
Definition: qglist.cpp:652
template<class type>
uint QStack< type >::count ( ) const
inlinevirtual

Returns the number of objects in the collection.

Reimplemented from QGList.

Definition at line 56 of file qstack.h.

56 { return QGList::count(); }
uint count() const
Definition: qglist.h:150
template<class type>
type* QStack< type >::current ( ) const
inline

Definition at line 65 of file qstack.h.

65 { return (type *)QGList::cfirst(); }
QCollection::Item cfirst() const
Definition: qglist.h:188
template<class type>
void QStack< type >::deleteItem ( 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 67 of file qstack.h.

67 { if ( del_item ) delete (type *)d; }
bool del_item
Definition: qcollection.h:67
template<class type>
bool QStack< type >::isEmpty ( ) const
inline

Definition at line 57 of file qstack.h.

57 { return QGList::count() == 0; }
uint count() const
Definition: qglist.h:150
template<class type>
QStack< type >::operator type * ( ) const
inline

Definition at line 64 of file qstack.h.

64 { return (type *)QGList::cfirst(); }
QCollection::Item cfirst() const
Definition: qglist.h:188
template<class type>
QStack<type>& QStack< type >::operator= ( const QStack< type > &  s)
inline

Definition at line 52 of file qstack.h.

53  { return (QStack<type>&)QGList::operator=(s); }
Definition: qstack.h:46
QGList & operator=(const QGList &)
Definition: qglist.cpp:222
template<class type>
type* QStack< type >::pop ( )
inline

Definition at line 59 of file qstack.h.

59 { return (type *)QGList::takeFirst(); }
QCollection::Item takeFirst()
Definition: qglist.cpp:623
template<class type>
void QStack< type >::push ( const type d)
inline

Definition at line 58 of file qstack.h.

58 { QGList::insertAt(0,Item(d)); }
bool insertAt(uint index, QCollection::Item)
Definition: qglist.cpp:384
void * Item
Definition: qcollection.h:60
template<class type>
bool QStack< type >::remove ( )
inline

Definition at line 60 of file qstack.h.

60 { return QGList::removeFirst(); }
bool removeFirst()
Definition: qglist.h:155
template<class type>
void QStack< type >::setAutoDelete ( bool  del)
inline

Definition at line 55 of file qstack.h.

void setAutoDelete(bool enable)
Definition: qcollection.h:55
template<class type>
type* QStack< type >::top ( ) const
inline

Definition at line 63 of file qstack.h.

63 { return (type *)QGList::cfirst(); }
QCollection::Item cfirst() const
Definition: qglist.h:188

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