Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QIntrusiveList< N, member > Class Template Reference

The QIntrusiveList class is a template class that provides a list of objects using static storage. More...

#include <qintrusivelist_p.h>

+ Collaboration diagram for QIntrusiveList< N, member >:

Classes

class  iterator
 

Public Types

typedef iterator Iterator
 

Public Member Functions

 QIntrusiveList ()
 Construct an empty list.
 
 ~QIntrusiveList ()
 Destroy the list.
 
bool isEmpty () const
 
void insert (N *n)
 Insert object into the list.
 
void remove (N *n)
 Remove object from the list.
 
bool contains (N *) const
 Returns true if the list contains object; otherwise returns false.
 
N * first () const
 Returns the first entry in this list, or null if the list is empty.
 
iterator begin ()
 Returns an STL-style interator pointing to the first item in the list.
 
iterator end ()
 Returns an STL-style iterator pointing to the imaginary item after the last item in the list.
 

Static Public Member Functions

static N * next (N *current)
 Returns the next object after current, or null if current is the last object.
 

Detailed Description

template<class N, QIntrusiveListNode N::* member>
class QIntrusiveList< N, member >

The QIntrusiveList class is a template class that provides a list of objects using static storage.

QIntrusiveList creates a linked list of objects. Adding and removing objects from the QIntrusiveList is a constant time operation and is very quick. The list performs no memory allocations, but does require the objects being added to the list to contain a QIntrusiveListNode instance for the list's use. Even so, for small lists QIntrusiveList uses less memory than Qt's other list classes.

As QIntrusiveList uses storage inside the objects in the list, each object can only be in one list at a time. Objects are inserted by the insert() method. If the object is already in a list (including the one it is being inserted into) it is first removed, and then inserted at the head of the list. QIntrusiveList is a last-in-first-out list. That is, following an insert() the inserted object becomes the list's first() object.

struct MyObject {
int value;
};
void foo() {
MyObjectList list;
MyObject m0(0);
MyObject m1(1);
MyObject m2(2);
list.insert(&m0);
list.insert(&m1);
list.insert(&m2);
// QIntrusiveList is LIFO, so will print: 2... 1... 0...
for (MyObjectList::iterator iter = list.begin(); iter != list.end(); ++iter) {
qWarning() << iter->value;
}
}
The QIntrusiveList class is a template class that provides a list of objects using static storage.
iterator insert(qsizetype i, parameter_type t)
Definition qlist.h:471
iterator end()
Definition qlist.h:609
iterator begin()
Definition qlist.h:608
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter * iter
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qWarning
Definition qlogging.h:162
QList< int > list
[14]
QString foo
[0]

Definition at line 24 of file qintrusivelist_p.h.

Member Typedef Documentation

◆ Iterator

template<class N , QIntrusiveListNode N::* member>
typedef iterator QIntrusiveList< N, member >::Iterator

Definition at line 51 of file qintrusivelist_p.h.

Constructor & Destructor Documentation

◆ QIntrusiveList()

template<class N , QIntrusiveListNode N::* member>
QIntrusiveList< N, member >::QIntrusiveList
inline

Construct an empty list.

Definition at line 131 of file qintrusivelist_p.h.

◆ ~QIntrusiveList()

template<class N , QIntrusiveListNode N::* member>
QIntrusiveList< N, member >::~QIntrusiveList
inline

Destroy the list.

All entries are removed.

Definition at line 137 of file qintrusivelist_p.h.

References QIntrusiveListNode::remove().

+ Here is the call graph for this function:

Member Function Documentation

◆ begin()

template<class N , QIntrusiveListNode N::* member>
QIntrusiveList< N, member >::iterator QIntrusiveList< N, member >::begin
inline

Returns an STL-style interator pointing to the first item in the list.

See also
end()

Definition at line 194 of file qintrusivelist_p.h.

Referenced by QQuickDragGrabber::begin(), QQmlDelegateModelGroupPrivate::createdPackage(), QQmlDelegateModelGroupPrivate::destroyingPackage(), QQmlDelegateModelGroupPrivate::emitModelUpdated(), QQmlDelegateModelGroupPrivate::initPackage(), QSGDistanceFieldGlyphCache::setGlyphsPosition(), and QSGDistanceFieldGlyphCache::setGlyphsTexture().

+ Here is the caller graph for this function:

◆ contains()

template<class N , QIntrusiveListNode N::* member>
bool QIntrusiveList< N, member >::contains ( N *  object) const
inline

Returns true if the list contains object; otherwise returns false.

Definition at line 168 of file qintrusivelist_p.h.

References QIntrusiveListNode::_next.

◆ end()

template<class N , QIntrusiveListNode N::* member>
QIntrusiveList< N, member >::iterator QIntrusiveList< N, member >::end
inline

Returns an STL-style iterator pointing to the imaginary item after the last item in the list.

See also
begin()

Definition at line 200 of file qintrusivelist_p.h.

Referenced by QQmlDelegateModelGroupPrivate::createdPackage(), QQmlDelegateModelGroupPrivate::destroyingPackage(), QQmlDelegateModelGroupPrivate::emitModelUpdated(), QQuickDragGrabber::end(), QQmlDelegateModelGroupPrivate::initPackage(), QSGDistanceFieldGlyphCache::setGlyphsPosition(), and QSGDistanceFieldGlyphCache::setGlyphsTexture().

+ Here is the caller graph for this function:

◆ first()

template<class N , QIntrusiveListNode N::* member>
N * QIntrusiveList< N, member >::first
inline

Returns the first entry in this list, or null if the list is empty.

Definition at line 180 of file qintrusivelist_p.h.

Referenced by QQuickDragGrabber::~QQuickDragGrabber(), QQuickPixmapData::~QQuickPixmapData(), QQmlIncubatorPrivate::clear(), QQmlIncubatorPrivate::forceCompletion(), and QQuickDragGrabber::target().

+ Here is the caller graph for this function:

◆ insert()

template<class N , QIntrusiveListNode N::* member>
void QIntrusiveList< N, member >::insert ( N *  object)
inline

Insert object into the list.

If object is a member of this, or another list, it will be removed and inserted at the head of this list.

Definition at line 149 of file qintrusivelist_p.h.

References QIntrusiveListNode::_next, QIntrusiveListNode::_prev, and QIntrusiveListNode::remove().

Referenced by QQmlPartsModel::QQmlPartsModel(), QQuickPixmapData::QQuickPixmapData(), QQuickPixmapData::QQuickPixmapData(), QQuickPixmapData::QQuickPixmapData(), QQuickPixmapData::QQuickPixmapData(), QQuickDragGrabber::grab(), QQmlDelegateModelPrivate::init(), QQuickPixmap::load(), QQuickPixmap::loadImageFromDevice(), QQuickPixmap::setPixmap(), QQmlDelegateModelPrivate::updateFilterGroup(), QQmlPartsModel::updateFilterGroup(), and QQmlPartsModel::updateFilterGroup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isEmpty()

template<class N , QIntrusiveListNode N::* member>
bool QIntrusiveList< N, member >::isEmpty
inline

Definition at line 143 of file qintrusivelist_p.h.

Referenced by QQuickDragGrabber::~QQuickDragGrabber(), QQuickPixmapData::~QQuickPixmapData(), QQmlIncubatorPrivate::calculateStatus(), QQmlIncubator::clear(), QQmlIncubatorPrivate::forceCompletion(), QQmlIncubatorPrivate::incubate(), QQuickDragGrabber::isEmpty(), and QQuickDragGrabber::target().

+ Here is the caller graph for this function:

◆ next()

template<class N , QIntrusiveListNode N::* member>
N * QIntrusiveList< N, member >::next ( N *  current)
inlinestatic

Returns the next object after current, or null if current is the last object.

current cannot be null.

Definition at line 186 of file qintrusivelist_p.h.

Referenced by QIntrusiveList< N, member >::iterator::erase(), and QIntrusiveList< N, member >::iterator::operator++().

+ Here is the caller graph for this function:

◆ remove()

template<class N , QIntrusiveListNode N::* member>
void QIntrusiveList< N, member >::remove ( N *  object)
inline

Remove object from the list.

object must not be null.

Definition at line 161 of file qintrusivelist_p.h.

References QIntrusiveListNode::remove().

Referenced by QIntrusiveListNode::~QIntrusiveListNode(), QQuickPixmap::~QQuickPixmap(), QQuickPixmapData::~QQuickPixmapData(), QQuickPixmap::clear(), QQuickPixmap::clear(), QIntrusiveList< N, member >::iterator::erase(), and QQuickPixmap::load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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