FX::QPtrVector< type > Class Template Reference
[Qt Template Library]

#include <qptrvector.h>

Inheritance diagram for FX::QPtrVector< type >:

List of all members.

Detailed Description

template<class type>
class FX::QPtrVector< type >

A thunk of Qt's QPtrVector to the STL.

A QPtrVector should be used when random access to elements needs to be quick. Insertions to and removals from the start of the list in particular are slow. Iterators are also invalidated whenever an insertion or removal is made. If you want something different, look into FX::QPtrList. This list is effectively a FX::QMemArray but with pointers and auto-deletion.

I've gone a bit further than Qt's QPtrVector as I've implemented all the QPtrList methods too - this was because the QPtrList code was used to make QPtrVector so it was trivial. Thus you can drop in a QPtrVector where a QPtrList used to be. I did however remove prepend() & removeFirst() as that's a major performance hurt with this container - use insert(0, x) or remove(0) instead. Qt doesn't seem to provide a QPtrVectorIterator, but we have.

Note that all sorts of unpleasantness has been used to get this work, including const_cast<>. Also, because of the nature of templates not being compiled until they are used, I may not have caught all the compile errors yet :(

Warning:
This list is much less forgiving of range errors than Qt. Where Qt returns false and prints a message, this list like the STL throws an exception!

Definition at line 71 of file qptrvector.h.

Public Member Functions

 QPtrVector (bool wantAutoDel=false)
 QPtrVector (std::vector< type * > &l)
 ~QPtrVector ()
bool autoDelete () const
void setAutoDelete (bool a)
type ** data () const
uint count () const
bool isEmpty () const
bool insert (uint i, const type *d)
bool insertAtIter (QPtrVectorIterator< type > &it, const type *d)
void inSort (const type *d)
void append (const type *d)
bool extend (uint no)
bool remove (uint i)
bool remove (const type *d)
bool removeRef (const type *d)
bool removeByIter (QPtrVectorIterator< type > &it)
bool removeLast ()
type * take (uint i)
bool take (const type *d)
bool takeRef (const type *d)
bool takeByIter (QPtrVectorIterator< type > &it)
bool takeLast ()
void clear ()
template<class SortFunc>
void sort (SortFunc sortfunc)
void sort ()
int find (const type *d)
int findRef (const type *d)
uint contains (const type *d) const
uint containsRef (const type *d) const
bool replace (uint i, const type *d, bool callDeleteItem=true)
bool replaceAtIter (QPtrVectorIterator< type > &it, const type *d, bool callDeleteItem=true)
type * at (uint i) const
type * operator[] (uint i) const
type * operator[] (int i) const
type * getFirst () const
type * getLast () const
type * first ()
type * last ()
virtual int compareItems (type *a, type *b) const
std::vector< type * > & int_vector ()
std::vector< type * >::iterator int_begin ()
std::vector< type * >::iterator int_end ()
template<>
void deleteItem (void *)

Protected Member Functions

virtual void deleteItem (type *d)


The documentation for this class was generated from the following file:
(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:37:43 2009 for TnFOX by doxygen v1.4.7