QCborArray::Iterator Class
class QCborArray::IteratorQCborArray::Iterator 类为QCborArray 提供了 STL 风格的非常数迭代器。更多
- 所有成员(包括继承成员)的列表
- Iterator 是Qt 中 CBOR 支持的一部分。
该类具有很强的可比性。
该类与QCborArray::ConstIterator 具有很强的可比性。
公共类型
公共函数
Iterator() | |
Iterator(const QCborArray::Iterator &other) | |
QCborValueRef | operator*() const |
QCborArray::Iterator | operator+(qsizetype j) const |
QCborArray::Iterator & | operator++() |
QCborArray::Iterator | operator++(int) |
QCborArray::Iterator & | operator+=(qsizetype j) |
qsizetype | operator-(QCborArray::Iterator other) const |
QCborArray::Iterator | operator-(qsizetype j) const |
QCborArray::Iterator & | operator--() |
QCborArray::Iterator | operator--(int) |
QCborArray::Iterator & | operator-=(qsizetype j) |
const QCborValueConstRef * | operator->() const |
QCborArray::Iterator & | operator=(const QCborArray::Iterator &other) |
QCborValueRef | operator[](qsizetype j) const |
相关非成员
bool | operator!=(const QCborArray::Iterator &lhs, const QCborArray::ConstIterator &rhs) |
bool | operator!=(const QCborArray::Iterator &lhs, const QCborArray::Iterator &rhs) |
bool | operator<(const QCborArray::Iterator &lhs, const QCborArray::ConstIterator &rhs) |
bool | operator<(const QCborArray::Iterator &lhs, const QCborArray::Iterator &rhs) |
bool | operator<=(const QCborArray::Iterator &lhs, const QCborArray::ConstIterator &rhs) |
bool | operator<=(const QCborArray::Iterator &lhs, const QCborArray::Iterator &rhs) |
bool | operator==(const QCborArray::Iterator &lhs, const QCborArray::ConstIterator &rhs) |
bool | operator==(const QCborArray::Iterator &lhs, const QCborArray::Iterator &rhs) |
bool | operator>(const QCborArray::Iterator &lhs, const QCborArray::ConstIterator &rhs) |
bool | operator>(const QCborArray::Iterator &lhs, const QCborArray::Iterator &rhs) |
bool | operator>=(const QCborArray::Iterator &lhs, const QCborArray::ConstIterator &rhs) |
bool | operator>=(const QCborArray::Iterator &lhs, const QCborArray::Iterator &rhs) |
详细描述
QCborArray::Iterator 允许您遍历 并修改与迭代器相关的数组项。如果要遍历常数 ,请使用 。一般来说,除非需要通过迭代器修改 ,否则在非常量 上使用 也是一种好的做法。常量迭代器速度稍快,代码可读性也更好。QCborArray QCborArray QCborArray::ConstIterator QCborArray QCborArray QCborArray::ConstIterator
迭代器通过QCborArray 函数初始化,如QCborArray::begin(),QCborArray::end() 或QCborArray::insert() 。之后才能进行迭代。
大多数QCborArray 函数接受的是整数索引而不是迭代器。因此,迭代器在QCborArray 中很少有用。STL 样式的迭代器确实有用的一个地方是作为generic algorithms 的参数。
在同一个数组中可以使用多个迭代器。不过,请注意在QCborArray 上执行的任何非const函数调用都会导致所有现有的迭代器都未定义。
另请参阅 QCborArray::ConstIterator 。
成员函数文档
[constexpr noexcept]
Iterator::Iterator()
构造一个未初始化的迭代器。
不应在未初始化的迭代器上调用 operator*() 和 operator++() 等函数。在使用迭代器之前,请使用 operator=() 为其赋值。
另请参阅 QCborArray::begin() 和QCborArray::end()。
[constexpr noexcept]
Iterator::Iterator(const QCborArray::Iterator &other)
复制other 。
QCborValueRef Iterator::operator*() const
返回当前项目的可修改引用。
您可以在赋值的左侧使用操作符*()来更改项的值。
返回值的类型是 QCborValueRef,它是QCborArray 和QCborMap 的辅助类。当获得 QCborValueRef 类型的对象时,可以将其作为QCborValue 的引用来使用。如果对其赋值,赋值将应用于QCborArray 或QCborMap 中的元素,而您正是通过该元素获得了引用。
QCborArray::Iterator Iterator::operator+(qsizetype j) const
返回位于j 位置的项目的迭代器。如果j 为负数,则迭代器向后退。
另请参阅 operator-() 和operator+=()。
QCborArray::Iterator &Iterator::operator++()
++
前缀操作符++it
将迭代器前进到数组中的下一项,并返回该迭代器。
在QCborArray::end() 上调用此函数会导致未定义的结果。
另请参见 operator--()。
QCborArray::Iterator Iterator::operator++(int)
这是一个重载函数。
后缀++
运算符it++
将迭代器前进到数组中的下一个项目,并返回一个指向先前当前项目的迭代器。
QCborArray::Iterator &Iterator::operator+=(qsizetype j)
将迭代器向前推进j 个位置。如果j 为负数,迭代器会向后退。返回对该迭代器的引用。
另请参阅 operator-=() 和operator+()。
qsizetype Iterator::operator-(QCborArray::Iterator other) const
返回该迭代器相对于other 的偏移量。
QCborArray::Iterator Iterator::operator-(qsizetype j) const
返回位于j 位置的项目的迭代器。如果j 为负数,则迭代器向前移动。
另请参阅 operator+() 和operator-=()。
QCborArray::Iterator &Iterator::operator--()
前缀--
操作符--it
使前一项成为当前项,并返回该迭代器。
在QCborArray::begin() 上调用此函数会导致未定义的结果。
另请参见 operator++()。
QCborArray::Iterator Iterator::operator--(int)
这是一个重载函数。
后缀--
运算符it--
使前一个项目成为当前项目,并返回一个指向前一个当前项目的迭代器。
QCborArray::Iterator &Iterator::operator-=(qsizetype j)
使迭代器返回j 位置。如果j 为负数,则迭代器向前移动。返回对该迭代器的引用。
另请参阅 operator+=() 和operator-()。
const QCborValueConstRef *Iterator::operator->() const
返回指向当前项目可修改引用的指针。
QCborArray::Iterator &Iterator::operator=(const QCborArray::Iterator &other)
使该迭代器成为other 的副本,并返回该迭代器的引用。
QCborValueRef Iterator::operator[](qsizetype j) const
返回从该迭代器指向的项目向前移动j 步的项目的可修改引用。
提供该函数是为了使QCborArray 迭代器的行为类似于 C++ 指针。
返回值的类型为 QCborValueRef,它是QCborArray 和QCborMap 的辅助类。当您获得 QCborValueRef 类型的对象时,可以像使用QCborValue 的引用一样使用它。如果对它进行赋值,赋值将应用于QCborArray 或QCborMap 中的元素,而您正是通过该元素获得了引用。
另请参阅 operator+()。
相关非成员
[noexcept]
bool operator==(const QCborArray::Iterator &lhs, const QCborArray::ConstIterator &rhs)
[noexcept]
bool operator==(const QCborArray::Iterator &lhs, const QCborArray::Iterator &rhs)
如果lhs 指向数组中与rhs 迭代器相同的条目,则返回true
;否则返回false
。
另请参阅 operator!=() 。
[noexcept]
bool operator!=(const QCborArray::Iterator &lhs, const QCborArray::ConstIterator &rhs)
[noexcept]
bool operator!=(const QCborArray::Iterator &lhs, const QCborArray::Iterator &rhs)
如果lhs 指向数组中与rhs 迭代器不同的条目,则返回true
;否则返回false
。
另请参阅 operator==() 。
[noexcept]
bool operator<(const QCborArray::Iterator &lhs, const QCborArray::ConstIterator &rhs)
[noexcept]
bool operator<(const QCborArray::Iterator &lhs, const QCborArray::Iterator &rhs)
如果lhs iterator 指向的数组条目出现在rhs iterator 指向的条目之前,则返回true
。
[noexcept]
bool operator<=(const QCborArray::Iterator &lhs, const QCborArray::ConstIterator &rhs)
[noexcept]
bool operator<=(const QCborArray::Iterator &lhs, const QCborArray::Iterator &rhs)
如果lhs iterator 指向的数组条目出现在rhs iterator 指向的条目之前,或者与 iterator 指向的条目相同,则返回true
。
[noexcept]
bool operator>(const QCborArray::Iterator &lhs, const QCborArray::ConstIterator &rhs)
[noexcept]
bool operator>(const QCborArray::Iterator &lhs, const QCborArray::Iterator &rhs)
如果lhs iterator 指向的数组条目位于rhs iterator 指向的条目之后,则返回true
。
[noexcept]
bool operator>=(const QCborArray::Iterator &lhs, const QCborArray::ConstIterator &rhs)
[noexcept]
bool operator>=(const QCborArray::Iterator &lhs, const QCborArray::Iterator &rhs)
如果lhs iterator 指向的数组条目出现在rhs iterator 指向的条目之后,或者与 iterator 指向的条目相同,则返回true
。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.