Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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

using const_iterator = iterator_impl<const N *>
 
using Iterator = iterator
 
using ConstIterator = const_iterator
 

Public Member Functions

 ~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 (const N *n) const
 Returns true if the list contains object; otherwise returns false.
 
const N * first () const
 Returns the first entry in this list, or null if the list is empty.
 
N * first ()
 
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.
 
const_iterator begin () const
 
const_iterator end () const
 

Static Public Member Functions

template<typename O >
static O next (O 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;
};
typedef QIntrusiveList<MyObject, &MyObject::node> MyObjectList;
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;
}
}
iterator insert(qsizetype i, parameter_type t)
Definition qlist.h:488
iterator end()
Definition qlist.h:626
iterator begin()
Definition qlist.h:625
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:166
QList< int > list
[14]
QString foo
[0]

Definition at line 46 of file qintrusivelist_p.h.

Member Typedef Documentation

◆ const_iterator

template<class N , QIntrusiveListNode N::* member>
using QIntrusiveList< N, member >::const_iterator = iterator_impl<const N *>

Definition at line 85 of file qintrusivelist_p.h.

◆ ConstIterator

template<class N , QIntrusiveListNode N::* member>
using QIntrusiveList< N, member >::ConstIterator = const_iterator

Definition at line 88 of file qintrusivelist_p.h.

◆ Iterator

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

Definition at line 87 of file qintrusivelist_p.h.

Constructor & Destructor Documentation

◆ ~QIntrusiveList()

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

Destroy the list.

All entries are removed.

Definition at line 90 of file qintrusivelist_p.h.

References QIntrusiveListNode::remove().

+ Here is the call graph for this function:

Member Function Documentation

◆ begin() [1/2]

template<class N , QIntrusiveListNode 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 132 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:

◆ begin() [2/2]

template<class N , QIntrusiveListNode N::* member>
const_iterator QIntrusiveList< N, member >::begin ( ) const
inline

Definition at line 135 of file qintrusivelist_p.h.

◆ contains()

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

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

Definition at line 111 of file qintrusivelist_p.h.

◆ end() [1/2]

template<class N , QIntrusiveListNode 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 133 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:

◆ end() [2/2]

template<class N , QIntrusiveListNode N::* member>
const_iterator QIntrusiveList< N, member >::end ( ) const
inline

Definition at line 140 of file qintrusivelist_p.h.

◆ first() [1/2]

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

Definition at line 123 of file qintrusivelist_p.h.

◆ first() [2/2]

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

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

Definition at line 122 of file qintrusivelist_p.h.

Referenced by QQuickDragGrabber::~QQuickDragGrabber(), 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 94 of file qintrusivelist_p.h.

References QIntrusiveListNode::remove().

Referenced by QQuickDragGrabber::grab().

+ 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 ( ) const
inline

Definition at line 92 of file qintrusivelist_p.h.

Referenced by QQuickDragGrabber::~QQuickDragGrabber(), 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>
template<typename O >
N * QIntrusiveList< N, member >::next ( O current)
inlinestatic

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

current cannot be null.

Definition at line 126 of file qintrusivelist_p.h.

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

+ 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 105 of file qintrusivelist_p.h.

References QIntrusiveListNode::remove().

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

+ 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: