QLinkedList Class | Qt Core 5.15.18 (original) (raw)
This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
Member Function Documentation
QLinkedList::QLinkedList(QLinkedList<T> &&other)
Move-constructs a QLinkedList instance, making it point at the same object that other was pointing to.
This function was introduced in Qt 5.2.
template QLinkedList::QLinkedList(InputIterator first, InputIterator last)
Constructs a list with the contents in the iterator range [first, last).
The value type of InputIterator
must be convertible to T
.
This function was introduced in Qt 5.14.
QLinkedList::QLinkedList(std::initializer_list<T> list)
Constructs a list from the std::initializer_list specified by list.
This constructor is only enabled if the compiler supports C++11 initializer lists.
This function was introduced in Qt 5.2.
QLinkedList::QLinkedList(const QLinkedList<T> &other)
Constructs a copy of other.
This operation occurs in constant time, because QLinkedList is implicitly shared. This makes returning a QLinkedList from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and this takes linear time.
See also operator=().
QLinkedList::QLinkedList()
Constructs an empty list.
QLinkedList<T> &QLinkedList::operator=(QLinkedList<T> &&other)
Move-assigns other to this QLinkedList instance.
This function was introduced in Qt 5.2.
QLinkedList<T> &QLinkedList::operator=(const QLinkedList<T> &other)
Assigns other to this list and returns a reference to this list.
QLinkedList::~QLinkedList()
Destroys the list. References to the values in the list, and all iterators over this list, become invalid.
void QLinkedList::append(const T &value)
Inserts value at the end of the list.
Example:
QLinkedList<QString> list; list.append("one"); list.append("two"); list.append("three"); // list: ["one", "two", "three"]
This is the same as list.insert(end(), value).
See also operator<<(), prepend(), and insert().
T &QLinkedList::back()
This function is provided for STL compatibility. It is equivalent to last().
const T &QLinkedList::back() const
This is an overloaded function.
QLinkedList::iterator QLinkedList::begin()
Returns an STL-style iterator pointing to the first item in the list.
See also constBegin() and end().
QLinkedList::const_iterator QLinkedList::begin() const
This is an overloaded function.
QLinkedList::const_iterator QLinkedList::cbegin() const
Returns a const STL-style iterator pointing to the first item in the list.
This function was introduced in Qt 5.0.
QLinkedList::const_iterator QLinkedList::cend() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list.
This function was introduced in Qt 5.0.
void QLinkedList::clear()
Removes all the items in the list.
See also removeAll().
QLinkedList::const_iterator QLinkedList::constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
See also begin() and constEnd().
QLinkedList::const_iterator QLinkedList::constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list.
See also constBegin() and end().
bool QLinkedList::contains(const T &value) const
Returns true
if the list contains an occurrence of value; otherwise returns false
.
This function requires the value type to have an implementation of operator==()
.
See also QLinkedListIterator::findNext() and QLinkedListIterator::findPrevious().
int QLinkedList::count(const T &value) const
Returns the number of occurrences of value in the list.
This function requires the value type to have an implementation of operator==()
.
See also contains().
int QLinkedList::count() const
Same as size().
QLinkedList::const_reverse_iterator QLinkedList::crbegin() const
Returns a const STL-style reverse iterator pointing to the first item in the list, in reverse order.
This function was introduced in Qt 5.6.
See also begin(), rbegin(), and rend().
QLinkedList::const_reverse_iterator QLinkedList::crend() const
Returns a const STL-style reverse iterator pointing to one past the last item in the list, in reverse order.
This function was introduced in Qt 5.6.
See also end(), rend(), and rbegin().
bool QLinkedList::empty() const
This function is provided for STL compatibility. It is equivalent to isEmpty() and returns true
if the list is empty.
QLinkedList::iterator QLinkedList::end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list.
See also begin() and constEnd().
QLinkedList::const_iterator QLinkedList::end() const
This is an overloaded function.
bool QLinkedList::endsWith(const T &value) const
Returns true
if the list is not empty and its last item is equal to value; otherwise returns false
.
This function was introduced in Qt 4.5.
See also isEmpty() and last().
QLinkedList::iterator QLinkedList::erase(QLinkedList::iterator pos)
Removes the item pointed to by the iterator pos from the list, and returns an iterator to the next item in the list (which may be end()).
See also insert().
QLinkedList::iterator QLinkedList::erase(QLinkedList::iterator begin, QLinkedList::iterator end)
This is an overloaded function.
Removes all the items from begin up to (but not including) end.
T &QLinkedList::first()
Returns a reference to the first item in the list. This function assumes that the list isn't empty.
See also last() and isEmpty().
const T &QLinkedList::first() const
This is an overloaded function.
[static]
QLinkedList<T> QLinkedList::fromStdList(const std::list<T> &list)
Returns a QLinkedList object with the data contained in list. The order of the elements in the QLinkedList is the same as in list.
Example:
std::list stdlist; list.push_back(1.2); list.push_back(0.5); list.push_back(3.14);
QLinkedList list = QLinkedList::fromStdList(stdlist);
This function was introduced in Qt 4.1.
See also toStdList().
T &QLinkedList::front()
This function is provided for STL compatibility. It is equivalent to first().
const T &QLinkedList::front() const
This is an overloaded function.
QLinkedList::iterator QLinkedList::insert(QLinkedList::iterator before, const T &value)
Inserts value in front of the item pointed to by the iterator before. Returns an iterator pointing at the inserted item.
See also erase().
bool QLinkedList::isEmpty() const
Returns true
if the list contains no items; otherwise returns false.
See also size().
T &QLinkedList::last()
Returns a reference to the last item in the list. This function assumes that the list isn't empty.
See also first() and isEmpty().
const T &QLinkedList::last() const
This is an overloaded function.
void QLinkedList::pop_back()
This function is provided for STL compatibility. It is equivalent to removeLast().
void QLinkedList::pop_front()
This function is provided for STL compatibility. It is equivalent to removeFirst().
void QLinkedList::prepend(const T &value)
Inserts value at the beginning of the list.
Example:
QLinkedList<QString> list; list.prepend("one"); list.prepend("two"); list.prepend("three"); // list: ["three", "two", "one"]
This is the same as list.insert(begin(), value).
See also append() and insert().
void QLinkedList::push_back(const T &value)
This function is provided for STL compatibility. It is equivalent to append(value).
void QLinkedList::push_front(const T &value)
This function is provided for STL compatibility. It is equivalent to prepend(value).
QLinkedList::reverse_iterator QLinkedList::rbegin()
Returns a STL-style reverse iterator pointing to the first item in the list, in reverse order.
This function was introduced in Qt 5.6.
See also begin(), crbegin(), and rend().
QLinkedList::const_reverse_iterator QLinkedList::rbegin() const
This is an overloaded function.
This function was introduced in Qt 5.6.
int QLinkedList::removeAll(const T &value)
Removes all occurrences of value in the list.
Example:
QList<QString> list; list << "sun" << "cloud" << "sun" << "rain"; list.removeAll("sun"); // list: ["cloud", "rain"]
This function requires the value type to have an implementation of operator==()
.
See also insert().
void QLinkedList::removeFirst()
Removes the first item in the list.
This is the same as erase(begin()).
See also removeLast() and erase().
void QLinkedList::removeLast()
Removes the last item in the list.
See also removeFirst() and erase().
bool QLinkedList::removeOne(const T &value)
Removes the first occurrences of value in the list. Returns true
on success; otherwise returns false
.
Example:
QList<QString> list; list << "sun" << "cloud" << "sun" << "rain"; list.removeOne("sun"); // list: ["cloud", "sun", "rain"]
This function requires the value type to have an implementation of operator==()
.
This function was introduced in Qt 4.4.
See also insert().
QLinkedList::reverse_iterator QLinkedList::rend()
Returns a STL-style reverse iterator pointing to one past the last item in the list, in reverse order.
This function was introduced in Qt 5.6.
See also end(), crend(), and rbegin().
QLinkedList::const_reverse_iterator QLinkedList::rend() const
This is an overloaded function.
This function was introduced in Qt 5.6.
int QLinkedList::size() const
Returns the number of items in the list.
See also isEmpty() and count().
bool QLinkedList::startsWith(const T &value) const
Returns true
if the list is not empty and its first item is equal to value; otherwise returns false
.
This function was introduced in Qt 4.5.
See also isEmpty() and first().
void QLinkedList::swap(QLinkedList<T> &other)
Swaps list other with this list. This operation is very fast and never fails.
This function was introduced in Qt 4.8.
T QLinkedList::takeFirst()
Removes the first item in the list and returns it.
If you don't use the return value, removeFirst() is more efficient.
See also takeLast() and removeFirst().
T QLinkedList::takeLast()
Removes the last item in the list and returns it.
If you don't use the return value, removeLast() is more efficient.
See also takeFirst() and removeLast().
std::list<T> QLinkedList::toStdList() const
Returns a std::list object with the data contained in this QLinkedList. Example:
QLinkedList list; list << 1.2 << 0.5 << 3.14;
std::list stdlist = list.toStdList();
This function was introduced in Qt 4.1.
See also fromStdList().
bool QLinkedList::operator!=(const QLinkedList<T> &other) const
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 function requires the value type to implement operator==()
.
See also operator==().
QLinkedList<T> QLinkedList::operator+(const QLinkedList<T> &other) const
Returns a list that contains all the items in this list followed by all the items in the other list.
See also operator+=().
QLinkedList<T> &QLinkedList::operator+=(const QLinkedList<T> &other)
Appends the items of the other list to this list and returns a reference to this list.
See also operator+() and append().
QLinkedList<T> &QLinkedList::operator+=(const T &value)
This is an overloaded function.
Appends value to the list.
QLinkedList<T> &QLinkedList::operator<<(const QLinkedList<T> &other)
Appends the items of the other list to this list and returns a reference to this list.
See also operator+=() and append().
QLinkedList<T> &QLinkedList::operator<<(const T &value)
This is an overloaded function.
Appends value to the list.
bool QLinkedList::operator==(const QLinkedList<T> &other) const
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 function requires the value type to implement operator==()
.
See also operator!=().