#include <qptrlist.h>
A QPtrList should be used when insertions to and removals from the centre of the list are common. Random access is slow with this list especially to near the end. If you want fast random access, use FX::QPtrVector. Iterators are not invalidated by insertions and removals.
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 :(
Public Member Functions | |
QPtrList (bool wantAutoDel=false) | |
QPtrList (std::list< type * > &l) | |
bool | autoDelete () const |
void | setAutoDelete (bool a) |
uint | count () const |
bool | isEmpty () const |
bool | insert (uint i, const type *d) |
bool | insertAtIter (QPtrListIterator< type > &it, 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 | removeByIter (QPtrListIterator< type > &it) |
bool | removeFirst () |
bool | removeLast () |
type * | take (uint i) |
bool | take (const type *d) |
bool | takeByIter (QPtrListIterator< type > &it) |
bool | takeRef (const type *d) |
bool | takeFirst () |
bool | takeLast () |
void | clear () |
template<typename SortFuncSpec> | |
void | sort (SortFuncSpec 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 | replaceAtIter (QPtrListIterator< type > &it, const type *d) |
type * | at (uint i) |
type * | getFirst () const |
type * | getLast () const |
type * | first () |
type * | last () |
virtual int | compareItems (type *a, type *b) const |
std::list< type * > & | int_list () |
std::list< type * >::iterator | int_begin () |
std::list< type * >::iterator | int_end () |
template<> | |
void | deleteItem (void *) |
Protected Member Functions | |
virtual void | deleteItem (type *d) |
bool FX::QPtrList< type >::autoDelete | ( | ) | const [inline] |
Returns if auto-deletion is enabled.
void FX::QPtrList< type >::setAutoDelete | ( | bool | a | ) | [inline] |
Sets if auto-deletion is enabled.
uint FX::QPtrList< type >::count | ( | ) | const [inline] |
Returns the number of items in the list.
Referenced by FX::QPtrList< type >::contains(), and FX::QPtrList< type >::containsRef().
bool FX::QPtrList< type >::isEmpty | ( | ) | const [inline] |
Returns true if the list is empty.
Referenced by FX::QPtrList< type >::remove(), FX::QPtrList< type >::removeFirst(), FX::QPtrList< type >::removeLast(), FX::QPtrList< type >::replace(), FX::QPtrList< type >::take(), FX::QPtrList< type >::takeFirst(), and FX::QPtrList< type >::takeLast().
bool FX::QPtrList< type >::insert | ( | uint | i, | |
const type * | d | |||
) | [inline] |
bool FX::QPtrList< type >::insertAtIter | ( | QPtrListIterator< type > & | it, | |
const type * | d | |||
) | [inline] |
Inserts item d into the list at where iterator it points.
References FXEXCEPTION_STL1, FXEXCEPTION_STL2, and FX::QPtrListIterator< type >::int_getIterator().
void FX::QPtrList< type >::inSort | ( | const type * | d | ) | [inline] |
Inserts item d into the list in its correct sorted order.
References FX::QPtrList< type >::compareItems(), FXEXCEPTION_STL1, and FXEXCEPTION_STL2.
void FX::QPtrList< type >::prepend | ( | const type * | d | ) | [inline] |
void FX::QPtrList< type >::append | ( | const type * | d | ) | [inline] |
bool FX::QPtrList< type >::remove | ( | uint | i | ) | [inline] |
bool FX::QPtrList< type >::remove | ( | const type * | d | ) | [inline] |
Removes the specified item d via compareItems().
Reimplemented in FX::QSortedList< type >.
References FX::QPtrList< type >::compareItems().
bool FX::QPtrList< type >::removeRef | ( | const type * | d | ) | [inline] |
Removes the specified item d via pointer compare (quicker).
Reimplemented in FX::QSortedList< type >.
bool FX::QPtrList< type >::removeByIter | ( | QPtrListIterator< type > & | it | ) | [inline] |
Removes the item pointed to by it (quickest).
References FX::QPtrListIterator< type >::int_getIterator().
bool FX::QPtrList< type >::removeFirst | ( | ) | [inline] |
bool FX::QPtrList< type >::removeLast | ( | ) | [inline] |
type* FX::QPtrList< type >::take | ( | uint | i | ) | [inline] |
bool FX::QPtrList< type >::take | ( | const type * | d | ) | [inline] |
Removes the specified item d via compareItems() without auto-deletion.
Reimplemented in FX::QSortedList< type >.
References FX::QPtrList< type >::compareItems().
bool FX::QPtrList< type >::takeByIter | ( | QPtrListIterator< type > & | it | ) | [inline] |
Removes the item pointed to by it without auto-deletion (quickest).
References FX::QPtrListIterator< type >::int_getIterator().
bool FX::QPtrList< type >::takeRef | ( | const type * | d | ) | [inline] |
Removes the specified item d via pointer compare (quicker) without auto-deletion.
Reimplemented in FX::QSortedList< type >.
bool FX::QPtrList< type >::takeFirst | ( | ) | [inline] |
bool FX::QPtrList< type >::takeLast | ( | ) | [inline] |
void FX::QPtrList< type >::clear | ( | ) | [inline] |
void FX::QPtrList< type >::sort | ( | SortFuncSpec | sortfunc | ) | [inline] |
Sorts the list using a user supplied callable entity taking two pointers of type type.
References FX::QValueListQSort< type, movePolicy, swapPolicy, comparePolicy >::run().
void FX::QPtrList< type >::sort | ( | ) | [inline] |
Sorts the list.
References FX::QValueListQSort< type, movePolicy, swapPolicy, comparePolicy >::run().
int FX::QPtrList< type >::find | ( | const type * | d | ) | [inline] |
Returns the index of the position of item d via compareItems(), or -1 if not found.
References FX::QPtrList< type >::compareItems().
int FX::QPtrList< type >::findRef | ( | const type * | d | ) | [inline] |
Returns the index of the position of item d via pointer compare, or -1 if not found.
uint FX::QPtrList< type >::contains | ( | const type * | d | ) | const [inline] |
Returns the number of item d in the list via compareItems().
References FX::QPtrList< type >::compareItems(), and FX::QPtrList< type >::count().
uint FX::QPtrList< type >::containsRef | ( | const type * | d | ) | const [inline] |
Returns the number of item d in the list via pointer compare.
References FX::QPtrList< type >::count().
bool FX::QPtrList< type >::replace | ( | uint | i, | |
const type * | d | |||
) | [inline] |
bool FX::QPtrList< type >::replaceAtIter | ( | QPtrListIterator< type > & | it, | |
const type * | d | |||
) | [inline] |
type* FX::QPtrList< type >::at | ( | uint | i | ) | [inline] |
Returns the item at index i.
type* FX::QPtrList< type >::getFirst | ( | ) | const [inline] |
Returns the first item in the list.
type* FX::QPtrList< type >::getLast | ( | ) | const [inline] |
Returns the last item in the list.
type* FX::QPtrList< type >::first | ( | ) | [inline] |
Returns the first item in the list.
type* FX::QPtrList< type >::last | ( | ) | [inline] |
Returns the last item in the list.
virtual int FX::QPtrList< type >::compareItems | ( | type * | a, | |
type * | b | |||
) | const [inline, virtual] |
Compares two items (used by many methods above). Default returns -1 if a < b, +1 if a > b and 0 if a==b.
Reimplemented in FX::QSortedList< type >.
Referenced by FX::QPtrList< type >::contains(), FX::QPtrList< type >::find(), FX::QPtrList< type >::inSort(), FX::QPtrList< type >::remove(), and FX::QPtrList< type >::take().