CopperSpice API
1.9.1
|
Template class which stores values in a linked list. More...
Classes | |
class | const_iterator |
The QLinkedList::const_iterator class provides an STL const iterator for QLinkedList More... | |
class | iterator |
The QLinkedList::iterator class provides an STL style iterator for QLinkedList More... | |
Public Typedefs | |
using | allocator_type = typename std::list< T >::allocator_type |
using | const_iterator = typename std::list< T >::const_iterator |
using | const_pointer = typename std::list< T >::const_pointer |
using | const_reference = typename std::list< T >::const_reference |
using | const_reverse_iterator = typename std::list< T >::const_reverse_iterator |
using | difference_type = typename std::list< T >::difference_type |
using | iterator = typename std::list< T >::iterator |
using | Java_Iterator = QLinkedListIterator< T > |
using | Java_MutableIterator = QMutableLinkedListIterator< T > |
using | pointer = typename std::list< T >::pointer |
using | reference = typename std::list< T >::reference |
using | reverse_iterator = typename std::list< T >::reverse_iterator |
using | size_type = typename std::list< T >::difference_type |
using | value_type = typename std::list< T >::value_type |
Public Methods | |
QLinkedList () = default | |
QLinkedList (const QLinkedList< T > &other) = default | |
template<class Input_Iterator > | |
QLinkedList (Input_Iterator first, Input_Iterator last) | |
QLinkedList (QLinkedList< T > &&other) = default | |
QLinkedList (std::initializer_list< T > args) | |
~QLinkedList () = default | |
void | append (const QLinkedList< T > &other) |
void | append (const T &value) |
void | append (T &&value) |
reference | back () |
const_reference | back () const |
iterator | begin () |
const_iterator | begin () const |
const_iterator | cbegin () const |
const_iterator | cend () const |
void | clear () |
const_iterator | constBegin () const |
const_iterator | constEnd () const |
bool | contains (const T &value) const |
size_type | count () const |
size_type | count (const T &value) const |
const_reverse_iterator | crbegin () const |
const_reverse_iterator | crend () const |
bool | empty () const |
iterator | end () |
const_iterator | end () const |
bool | endsWith (const T &value) const |
iterator | erase (const_iterator begin, const_iterator end) |
iterator | erase (const_iterator pos) |
reference | first () |
const_reference | first () const |
reference | front () |
const_reference | front () const |
iterator | insert (iterator before, const T &value) |
iterator | insert (iterator before, size_type count, const T &value) |
bool | isEmpty () const |
reference | last () |
const_reference | last () const |
size_type | length () const |
bool | operator!= (const QLinkedList< T > &other) const |
QLinkedList< T > | operator+ (const QLinkedList< T > &other) const |
QLinkedList< T > & | operator+= (const QLinkedList< T > &other) |
QLinkedList< T > & | operator+= (const T &value) |
QLinkedList< T > & | operator<< (const QLinkedList< T > &other) |
QLinkedList< T > & | operator<< (const T &value) |
QLinkedList< T > & | operator= (const QLinkedList< T > &other) = default |
QLinkedList< T > & | operator= (QLinkedList< T > &&other) = default |
bool | operator== (const QLinkedList< T > &other) const |
void | pop_back () |
void | pop_front () |
void | prepend (const T &value) |
void | push_back (const T &value) |
void | push_front (const T &value) |
reverse_iterator | rbegin () |
const_reverse_iterator | rbegin () const |
size_type | removeAll (const T &value) |
void | removeFirst () |
void | removeLast () |
bool | removeOne (const T &value) |
reverse_iterator | rend () |
const_reverse_iterator | rend () const |
size_type | size () const |
bool | startsWith (const T &value) const |
void | swap (QLinkedList< T > &other) |
T | takeFirst () |
T | takeLast () |
std::list< T > | toStdList () const |
Static Public Methods | |
static QLinkedList< T > | fromStdList (const std::list< T > &other) |
Related Functions | |
These are not member functions | |
QDataStream & | operator<< (QDataStream &stream, const QLinkedList< T > &list) |
QDataStream & | operator>> (QDataStream &stream, QLinkedList< T > &list) |
The QLinkedList is a template class which stores values in a linked list. This container is implemented using a doubly linked list which means adding or removing elements are fast anywhere in the linked list.
For an overview and comparison of all containers, refer to the documentation for Container Classes. Refer to the section on Time Complexity for a discussion about which operations will be relatively faster or slower for a given container with a size of n.
The following code is a simple example showing how to declare a QLinkedList.
To insert items into a QLinkedList the operator<<() method can be used.
To get the first or last item in a linked list use first() or last(). If you want to remove an item from either end of the list, use removeFirst() or removeLast(). If you want to remove all occurrences of a given value in the list, use removeAll().
A common requirement is to remove the first or last item in the list and do something with it. QLinkedList provides takeFirst() and takeLast().
The following is a loop which removes the items from a list one at a time and calls delete
on them.
The QVector value type T should be Default Constructible and Copy Constructible to work with all methods of this class. Data types like QObject are not copy constructible and therefore should never be stored in a container. You can however use a pointer to a QObject or any subclass as the type T.
To insert, modify, or remove items in the middle of the list use an iterator. QLinkedList provides both Java style iterators (QLinkedListIterator and QMutableLinkedListIterator) and STL style iterators (QLinkedList::const_iterator and QLinkedList::iterator).
QLinkedList< T >::allocator_type |
Typedef for allocator used by the container.
QLinkedList< T >::const_iterator |
Typedef for std::list<T>::const_iterator.
QLinkedList< T >::const_pointer |
Typedef for const T *.
QLinkedList< T >::const_reference |
Typedef for const T &.
QLinkedList< T >::const_reverse_iterator |
Typedef for an STL style const reverse iterator.
QLinkedList< T >::difference_type |
Typedef for ptrdiff_t.
QLinkedList< T >::iterator |
Typedef for std::list<T>::iterator.
QLinkedList< T >::Java_Iterator |
Typedef for the java style const iterator.
QLinkedList< T >::Java_MutableIterator |
Typedef for the java style mutable iterator.
QLinkedList< T >::pointer |
Typedef for T *.
QLinkedList< T >::reference |
Typedef for T &.
QLinkedList< T >::reverse_iterator |
Typedef for an STL style reverse iterator.
QLinkedList< T >::size_type |
Typedef for int.
QLinkedList< T >::value_type |
Typedef for T.
|
default |
Constructs an empty list.
|
default |
Copy constructs a new QLinkList from other.
|
default |
Move constructs a new QLinkList from other.
|
inline |
Construct a linked list from the std::initializer_list specified by args.
|
inline |
Construct a linked list containing the elements from first to last.
|
default |
Destroys the QLinkedList.
|
inline |
Copy appends the items of value to this QLinkedList.
|
inline |
Copy append value at the end of the list.
Equivalent to calling list.insert(end(), value).
|
inline |
Move appends from value to this QLinkedList.
|
inline |
Returns a reference to the last element. Equivalent to calling last().
|
inline |
Returns a const reference to the last element. Equivalent to calling last().
|
inline |
Returns an STL style iterator pointing to the first item in the list.
|
inline |
Returns a const STL style iterator pointing to the first item in the list.
|
inline |
Returns a const STL style iterator positioned at the first item in the set.
|
inline |
Returns a const STL style iterator pointing to the imaginary item after the last item in the set.
|
inline |
Removes all the items in the list.
|
inline |
Returns a const STL style iterator pointing to the first item in the list.
|
inline |
Returns a const STL style iterator pointing to the imaginary item after the last item in the list.
bool QLinkedList< T >::contains | ( | const T & | value | ) | const |
Returns true if the list contains an occurrence of value, otherwise returns false. This method requires the type T to support operator==()
.
QLinkedList< T >::size_type QLinkedList< T >::count | ( | const T & | value | ) | const |
Returns the number of occurrences of value in the list. This method requires the type T to support operator==()
.
|
inline |
Returns a const STL style reverse iterator pointing to the first item in the list, in reverse order.
|
inline |
Returns a const STL style reverse iterator pointing to one past the last item in the list, in reverse order.
|
inline |
Equivalent to calling isEmpty().
|
inline |
Returns an STL style iterator pointing to the imaginary item after the last item in the list.
|
inline |
Returns a const STL style iterator pointing to the imaginary item after the last item in the list.
|
inline |
|
inline |
Removes all the items from begin up to (but not including) end.
|
inline |
|
inline |
|
inline |
This is an overloaded method.
|
inlinestatic |
Returns a QLinkedList object with the data contained in other. The order of the elements in the QLinkedList is the same as in list.
|
inline |
Equivalent to calling first().
Inserts value in front of the item pointed to by the iterator before. Returns an iterator pointing at the inserted item.
|
inline |
Inserts count copies of value in front of the item pointed to by the iterator before. Returns an iterator pointing at the inserted item.
|
inline |
Returns true if the list contains no items, otherwise returns false.
|
inline |
|
inline |
This is an overloaded method.
|
inline |
Equivalent to calling size().
|
inline |
Returns true if other is not equal to this list, otherwise returns false. Two lists are considered equal if they contain the same values in the same order.
This method requires the type T to support operator==()
.
|
inline |
Returns a list that contains all the items in this list followed by all the items in the other list.
QLinkedList< T > & QLinkedList< T >::operator+= | ( | const QLinkedList< T > & | other | ) |
Appends the items of the other list to this list and returns a reference to this list.
|
inline |
Appends value to the list.
|
inline |
Appends the items of the other list to this list and returns a reference to this list.
|
inline |
Appends value to the list.
|
default |
Copy assigns from other and returns a reference to this object.
|
default |
Move assigns from other and returns a reference to this object.
This version takes an rvalue. Refer to references for a detailed description of rvalues and move semantics.
|
inline |
Returns true if other is equal to this list, otherwise returns false. Two lists are considered equal if they contain the same values in the same order.
This method requires the type T to support operator==()
.
|
inline |
Equivalent to calling removeLast().
|
inline |
Equivalent to calling removeFirst().
|
inline |
|
inline |
Equivalent to calling append(value).
|
inline |
Equivalent to calling prepend(value).
|
inline |
Returns a const STL style reverse iterator pointing to the first item in the list, in reverse order.
|
inline |
This is an overloaded method.
QLinkedList< T >::size_type QLinkedList< T >::removeAll | ( | const T & | value | ) |
Removes all occurrences of value in the list.
This method requires the type T to support operator==()
.
|
inline |
Removes the first item in the list. Equivalent to calling erase(begin()).
|
inline |
Removes the last item in the list.
bool QLinkedList< T >::removeOne | ( | const T & | value | ) |
Removes the first occurrences of value in the list. Returns true on success, otherwise returns false.
This method requires the type T to support operator==()
.
|
inline |
Returns a const STL style reverse iterator pointing to one past the last item in the list, in reverse order.
|
inline |
This is an overloaded method.
|
inline |
|
inline |
|
inline |
Swaps list other with this list. This operation is very fast and never fails.
|
inline |
Removes the first item in the list and returns it.
If you do not use the return value, removeFirst() is more efficient.
|
inline |
Removes the last item in the list and returns it.
If you do not use the return value, removeLast() is more efficient.
|
inline |
Returns a std::list object with the data contained in this QLinkedList.
|
related |
Writes the given list to the stream. Returns a reference to the stream. This function requires the type T to support operator<<()
.
Refer to Serializing Data Types for additional information.
|
related |
Reads from the stream into the given list. Returns a reference to the stream. This function requires the type T to support operator>>()
.
Refer to Serializing Data Types for additional information.