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

#include <qptrvector.h>

Inheritance diagram for FX::QPtrVector< type >:

Inheritance graph
[legend]

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!

Public Member Functions

 QPtrVector (bool wantAutoDel=false)
 QPtrVector (std::vector< type * > &l)
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)

Member Function Documentation

template<class type>
bool FX::QPtrVector< type >::autoDelete (  )  const [inline]

Returns if auto-deletion is enabled.

template<class type>
void FX::QPtrVector< type >::setAutoDelete ( bool  a  )  [inline]

Sets if auto-deletion is enabled.

template<class type>
type** FX::QPtrVector< type >::data (  )  const [inline]

Returns the raw array of pointers.

template<class type>
uint FX::QPtrVector< type >::count (  )  const [inline]

Returns the number of items in the list.

Referenced by FX::QPtrVector< TnFXGraphItem >::contains(), and FX::QPtrVector< TnFXGraphItem >::containsRef().

template<class type>
bool FX::QPtrVector< type >::isEmpty (  )  const [inline]

template<class type>
bool FX::QPtrVector< type >::insert ( uint  i,
const type *  d 
) [inline]

Inserts item d into the list at index i.

template<class type>
bool FX::QPtrVector< type >::insertAtIter ( QPtrVectorIterator< type > &  it,
const type *  d 
) [inline]

Inserts item d into the list at where iterator it points.

References FXEXCEPTION_STL1, FXEXCEPTION_STL2, and FX::QPtrVectorIterator< type >::int_getIterator().

template<class type>
void FX::QPtrVector< type >::inSort ( const type *  d  )  [inline]

Inserts item d into the list in its correct sorted order.

template<class type>
void FX::QPtrVector< type >::append ( const type *  d  )  [inline]

Appends the item d onto the list.

template<class type>
bool FX::QPtrVector< type >::extend ( uint  no  )  [inline]

Extends the list to no items if not that already.

template<class type>
bool FX::QPtrVector< type >::remove ( uint  i  )  [inline]

Removes the item at index i.

template<class type>
bool FX::QPtrVector< type >::remove ( const type *  d  )  [inline]

Removes the specified item d via compareItems().

template<class type>
bool FX::QPtrVector< type >::removeRef ( const type *  d  )  [inline]

Removes the specified item d via pointer compare (quicker).

template<class type>
bool FX::QPtrVector< type >::removeByIter ( QPtrVectorIterator< type > &  it  )  [inline]

Removes the item pointed to by it (quickest).

References FX::QPtrVectorIterator< type >::int_getIterator().

template<class type>
bool FX::QPtrVector< type >::removeLast (  )  [inline]

Removes the last item.

template<class type>
type* FX::QPtrVector< type >::take ( uint  i  )  [inline]

Removes the item at index i without auto-deletion.

template<class type>
bool FX::QPtrVector< type >::take ( const type *  d  )  [inline]

Removes the specified item d via compareItems() without auto-deletion.

template<class type>
bool FX::QPtrVector< type >::takeRef ( const type *  d  )  [inline]

Removes the specified item d via pointer compare (quicker) without auto-deletion.

template<class type>
bool FX::QPtrVector< type >::takeByIter ( QPtrVectorIterator< type > &  it  )  [inline]

Removes the item pointed to by it without auto-deletion (quickest).

References FX::QPtrVectorIterator< type >::int_getIterator().

template<class type>
bool FX::QPtrVector< type >::takeLast (  )  [inline]

Removes the last item without auto-deletion.

template<class type>
void FX::QPtrVector< type >::clear (  )  [inline]

Clears the list.

template<class type>
template<class SortFunc>
void FX::QPtrVector< type >::sort ( SortFunc  sortfunc  )  [inline]

Sorts the list using a user supplied callable entity taking two pointers of type type.

template<class type>
void FX::QPtrVector< type >::sort (  )  [inline]

Sorts the list.

template<class type>
int FX::QPtrVector< type >::find ( const type *  d  )  [inline]

Returns the index of the position of item d via compareItems(), or -1 if not found.

template<class type>
int FX::QPtrVector< type >::findRef ( const type *  d  )  [inline]

Returns the index of the position of item d via pointer compare, or -1 if not found.

template<class type>
uint FX::QPtrVector< type >::contains ( const type *  d  )  const [inline]

Returns the number of item d in the list via compareItems().

template<class type>
uint FX::QPtrVector< type >::containsRef ( const type *  d  )  const [inline]

Returns the number of item d in the list via pointer compare.

template<class type>
bool FX::QPtrVector< type >::replace ( uint  i,
const type *  d,
bool  callDeleteItem = true 
) [inline]

Replaces item at index i with d.

template<class type>
bool FX::QPtrVector< type >::replaceAtIter ( QPtrVectorIterator< type > &  it,
const type *  d,
bool  callDeleteItem = true 
) [inline]

Replaces item at iterator with d.

References FX::QPtrVectorIterator< type >::int_getIterator().

template<class type>
type* FX::QPtrVector< type >::at ( uint  i  )  const [inline]

Returns the item at index i.

template<class type>
type* FX::QPtrVector< type >::getFirst (  )  const [inline]

Returns the first item in the list.

template<class type>
type* FX::QPtrVector< type >::getLast (  )  const [inline]

Returns the last item in the list.

template<class type>
type* FX::QPtrVector< type >::first (  )  [inline]

Returns the first item in the list.

template<class type>
type* FX::QPtrVector< type >::last (  )  [inline]

Returns the last item in the list.

template<class type>
virtual int FX::QPtrVector< type >::compareItems ( type *  a,
type *  b 
) const [inline, virtual]


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

(C) 2002-2008 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Jun 13 22:28:37 2008 for TnFOX by doxygen v1.5.6