Struct qt_core::q_map_of_q_string_q_variant::KeyIterator
source · #[repr(C)]pub struct KeyIterator { /* private fields */ }
Expand description
The QMap::key_iterator class provides an STL-style const iterator for QMap and QMultiMap keys.
C++ class: QMap<QString, QVariant>::key_iterator
.
The QMap::key_iterator class provides an STL-style const iterator for QMap and QMultiMap keys.
QMap::key_iterator is essentially the same as QMap::const_iterator with the difference that operator*() and operator->() return a key instead of a value.
For most uses QMap::iterator and QMap::const_iterator should be used, you can easily access the key by calling QMap::iterator::key():
for (QMap<int, QString>::const_iterator it = map.cbegin(), end = map.cend(); it != end; ++it) { cout << “The key: “ << it.key() << endl cout << “The value: “ << it.value() << endl; cout << “Also the value: “ << (*it) << endl; }
However, to have interoperability between QMap's keys and STL-style algorithms we need an iterator that dereferences to a key instead of a value. With QMap::key_iterator we can apply an algorithm to a range of keys without having to call QMap::keys(), which is inefficient as it costs one QMap iteration and memory allocation to create a temporary QList.
// Inefficient, keys() is expensive QList<int> keys = map.keys(); int numPrimes = std::count_if(map.cbegin(), map.cend(), isPrimeNumber); qDeleteAll(map2.keys());
// Efficient, no memory allocation needed int numPrimes = std::count_if(map.keyBegin(), map.keyEnd(), isPrimeNumber); qDeleteAll(map2.keyBegin(), map2.keyEnd());
QMap::key_iterator is const, it's not possible to modify the key.
The default QMap::key_iterator constructor creates an uninitialized iterator. You must initialize it using a QMap function like QMap::keyBegin() or QMap::keyEnd().
Warning: Iterators on implicitly shared containers do not work exactly like STL-iterators. You should avoid copying a container while iterators are active on that container. For more information, read Implicit sharing iterator problem.
Implementations§
source§impl KeyIterator
impl KeyIterator
sourcepub unsafe fn base(&self) -> CppBox<ConstIterator>
pub unsafe fn base(&self) -> CppBox<ConstIterator>
Returns the underlying const_iterator this key_iterator is based on.
Calls C++ function: QMap<QString, QVariant>::const_iterator QMap<QString, QVariant>::key_iterator::base() const
.
Returns the underlying const_iterator this key_iterator is based on.
sourcepub unsafe fn copy_from(
&self,
other: impl CastInto<Ref<KeyIterator>>
) -> Ref<KeyIterator>
pub unsafe fn copy_from( &self, other: impl CastInto<Ref<KeyIterator>> ) -> Ref<KeyIterator>
The QMap::key_iterator class provides an STL-style const iterator for QMap and QMultiMap keys.
Calls C++ function: QMap<QString, QVariant>::key_iterator& QMap<QString, QVariant>::key_iterator::operator=(const QMap<QString, QVariant>::key_iterator& other)
.
The QMap::key_iterator class provides an STL-style const iterator for QMap and QMultiMap keys.
QMap::key_iterator is essentially the same as QMap::const_iterator with the difference that operator*() and operator->() return a key instead of a value.
For most uses QMap::iterator and QMap::const_iterator should be used, you can easily access the key by calling QMap::iterator::key():
for (QMap<int, QString>::const_iterator it = map.cbegin(), end = map.cend(); it != end; ++it) { cout << “The key: “ << it.key() << endl cout << “The value: “ << it.value() << endl; cout << “Also the value: “ << (*it) << endl; }
However, to have interoperability between QMap's keys and STL-style algorithms we need an iterator that dereferences to a key instead of a value. With QMap::key_iterator we can apply an algorithm to a range of keys without having to call QMap::keys(), which is inefficient as it costs one QMap iteration and memory allocation to create a temporary QList.
// Inefficient, keys() is expensive QList<int> keys = map.keys(); int numPrimes = std::count_if(map.cbegin(), map.cend(), isPrimeNumber); qDeleteAll(map2.keys());
// Efficient, no memory allocation needed int numPrimes = std::count_if(map.keyBegin(), map.keyEnd(), isPrimeNumber); qDeleteAll(map2.keyBegin(), map2.keyEnd());
QMap::key_iterator is const, it's not possible to modify the key.
The default QMap::key_iterator constructor creates an uninitialized iterator. You must initialize it using a QMap function like QMap::keyBegin() or QMap::keyEnd().
Warning: Iterators on implicitly shared containers do not work exactly like STL-iterators. You should avoid copying a container while iterators are active on that container. For more information, read Implicit sharing iterator problem.
sourcepub unsafe fn dec(&self) -> Ref<KeyIterator>
pub unsafe fn dec(&self) -> Ref<KeyIterator>
The prefix -- operator (--i
) makes the preceding item current and returns an iterator pointing to the new current item.
Calls C++ function: QMap<QString, QVariant>::key_iterator& QMap<QString, QVariant>::key_iterator::operator--()
.
The prefix – operator (–i
) makes the preceding item current and returns an iterator pointing to the new current item.
Calling this function on QHash::keyBegin() leads to undefined results.
See also operator++().
sourcepub unsafe fn dec_postfix(&self, arg1: c_int) -> CppBox<KeyIterator>
pub unsafe fn dec_postfix(&self, arg1: c_int) -> CppBox<KeyIterator>
This is an overloaded function.
Calls C++ function: QMap<QString, QVariant>::key_iterator QMap<QString, QVariant>::key_iterator::operator--(int arg1)
.
This is an overloaded function.
The postfix -- operator (i--
) makes the preceding item current and returns an iterator pointing to the previous item.
sourcepub unsafe fn inc(&self) -> Ref<KeyIterator>
pub unsafe fn inc(&self) -> Ref<KeyIterator>
The prefix ++ operator (++i
) advances the iterator to the next item in the hash and returns an iterator to the new current item.
Calls C++ function: QMap<QString, QVariant>::key_iterator& QMap<QString, QVariant>::key_iterator::operator++()
.
The prefix ++ operator (++i
) advances the iterator to the next item in the hash and returns an iterator to the new current item.
Calling this function on QHash::keyEnd() leads to undefined results.
See also operator--().
sourcepub unsafe fn inc_postfix(&self, arg1: c_int) -> CppBox<KeyIterator>
pub unsafe fn inc_postfix(&self, arg1: c_int) -> CppBox<KeyIterator>
This is an overloaded function.
Calls C++ function: QMap<QString, QVariant>::key_iterator QMap<QString, QVariant>::key_iterator::operator++(int arg1)
.
This is an overloaded function.
The postfix ++ operator (i++
) advances the iterator to the next item in the hash and returns an iterator to the previous item.
sourcepub unsafe fn indirection(&self) -> Ref<QString>
pub unsafe fn indirection(&self) -> Ref<QString>
Returns the current item's key.
Calls C++ function: const QString& QMap<QString, QVariant>::key_iterator::operator*() const
.
Returns the current item’s key.
sourcepub unsafe fn new_0a() -> CppBox<KeyIterator>
pub unsafe fn new_0a() -> CppBox<KeyIterator>
Default constructs an instance of key_iterator.
Calls C++ function: [constructor] void QMap<QString, QVariant>::key_iterator::key_iterator()
.
Default constructs an instance of key_iterator.
sourcepub unsafe fn new_1a(
o: impl CastInto<Ref<ConstIterator>>
) -> CppBox<KeyIterator>
pub unsafe fn new_1a( o: impl CastInto<Ref<ConstIterator>> ) -> CppBox<KeyIterator>
Calls C++ function: [constructor] void QMap<QString, QVariant>::key_iterator::key_iterator(QMap<QString, QVariant>::const_iterator o)
.
sourcepub unsafe fn new_copy(
other: impl CastInto<Ref<KeyIterator>>
) -> CppBox<KeyIterator>
pub unsafe fn new_copy( other: impl CastInto<Ref<KeyIterator>> ) -> CppBox<KeyIterator>
The QMap::key_iterator class provides an STL-style const iterator for QMap and QMultiMap keys.
Calls C++ function: [constructor] void QMap<QString, QVariant>::key_iterator::key_iterator(const QMap<QString, QVariant>::key_iterator& other)
.
The QMap::key_iterator class provides an STL-style const iterator for QMap and QMultiMap keys.
QMap::key_iterator is essentially the same as QMap::const_iterator with the difference that operator*() and operator->() return a key instead of a value.
For most uses QMap::iterator and QMap::const_iterator should be used, you can easily access the key by calling QMap::iterator::key():
for (QMap<int, QString>::const_iterator it = map.cbegin(), end = map.cend(); it != end; ++it) { cout << “The key: “ << it.key() << endl cout << “The value: “ << it.value() << endl; cout << “Also the value: “ << (*it) << endl; }
However, to have interoperability between QMap's keys and STL-style algorithms we need an iterator that dereferences to a key instead of a value. With QMap::key_iterator we can apply an algorithm to a range of keys without having to call QMap::keys(), which is inefficient as it costs one QMap iteration and memory allocation to create a temporary QList.
// Inefficient, keys() is expensive QList<int> keys = map.keys(); int numPrimes = std::count_if(map.cbegin(), map.cend(), isPrimeNumber); qDeleteAll(map2.keys());
// Efficient, no memory allocation needed int numPrimes = std::count_if(map.keyBegin(), map.keyEnd(), isPrimeNumber); qDeleteAll(map2.keyBegin(), map2.keyEnd());
QMap::key_iterator is const, it's not possible to modify the key.
The default QMap::key_iterator constructor creates an uninitialized iterator. You must initialize it using a QMap function like QMap::keyBegin() or QMap::keyEnd().
Warning: Iterators on implicitly shared containers do not work exactly like STL-iterators. You should avoid copying a container while iterators are active on that container. For more information, read Implicit sharing iterator problem.
sourcepub unsafe fn struct_deref(&self) -> Ptr<QString>
pub unsafe fn struct_deref(&self) -> Ptr<QString>
Returns a pointer to the current item's key.
Calls C++ function: const QString* QMap<QString, QVariant>::key_iterator::operator->() const
.
Returns a pointer to the current item’s key.
Trait Implementations§
source§impl CppDeletable for KeyIterator
impl CppDeletable for KeyIterator
source§unsafe fn delete(&self)
unsafe fn delete(&self)
The QMap::key_iterator class provides an STL-style const iterator for QMap and QMultiMap keys.
Calls C++ function: [destructor] void QMap<QString, QVariant>::key_iterator::~key_iterator()
.
The QMap::key_iterator class provides an STL-style const iterator for QMap and QMultiMap keys.
QMap::key_iterator is essentially the same as QMap::const_iterator with the difference that operator*() and operator->() return a key instead of a value.
For most uses QMap::iterator and QMap::const_iterator should be used, you can easily access the key by calling QMap::iterator::key():
for (QMap<int, QString>::const_iterator it = map.cbegin(), end = map.cend(); it != end; ++it) { cout << “The key: “ << it.key() << endl cout << “The value: “ << it.value() << endl; cout << “Also the value: “ << (*it) << endl; }
However, to have interoperability between QMap's keys and STL-style algorithms we need an iterator that dereferences to a key instead of a value. With QMap::key_iterator we can apply an algorithm to a range of keys without having to call QMap::keys(), which is inefficient as it costs one QMap iteration and memory allocation to create a temporary QList.
// Inefficient, keys() is expensive QList<int> keys = map.keys(); int numPrimes = std::count_if(map.cbegin(), map.cend(), isPrimeNumber); qDeleteAll(map2.keys());
// Efficient, no memory allocation needed int numPrimes = std::count_if(map.keyBegin(), map.keyEnd(), isPrimeNumber); qDeleteAll(map2.keyBegin(), map2.keyEnd());
QMap::key_iterator is const, it's not possible to modify the key.
The default QMap::key_iterator constructor creates an uninitialized iterator. You must initialize it using a QMap function like QMap::keyBegin() or QMap::keyEnd().
Warning: Iterators on implicitly shared containers do not work exactly like STL-iterators. You should avoid copying a container while iterators are active on that container. For more information, read Implicit sharing iterator problem.
source§impl Decrement for KeyIterator
impl Decrement for KeyIterator
source§unsafe fn dec(&self) -> Ref<KeyIterator>
unsafe fn dec(&self) -> Ref<KeyIterator>
The prefix -- operator (--i
) makes the preceding item current and returns an iterator pointing to the new current item.
Calls C++ function: QMap<QString, QVariant>::key_iterator& QMap<QString, QVariant>::key_iterator::operator--()
.
The prefix – operator (–i
) makes the preceding item current and returns an iterator pointing to the new current item.
Calling this function on QHash::keyBegin() leads to undefined results.
See also operator++().
§type Output = Ref<KeyIterator>
type Output = Ref<KeyIterator>
source§impl Increment for KeyIterator
impl Increment for KeyIterator
source§unsafe fn inc(&self) -> Ref<KeyIterator>
unsafe fn inc(&self) -> Ref<KeyIterator>
The prefix ++ operator (++i
) advances the iterator to the next item in the hash and returns an iterator to the new current item.
Calls C++ function: QMap<QString, QVariant>::key_iterator& QMap<QString, QVariant>::key_iterator::operator++()
.
The prefix ++ operator (++i
) advances the iterator to the next item in the hash and returns an iterator to the new current item.
Calling this function on QHash::keyEnd() leads to undefined results.
See also operator--().
§type Output = Ref<KeyIterator>
type Output = Ref<KeyIterator>
source§impl Indirection for KeyIterator
impl Indirection for KeyIterator
source§unsafe fn indirection(&self) -> Ref<QString>
unsafe fn indirection(&self) -> Ref<QString>
Returns the current item's key.
Calls C++ function: const QString& QMap<QString, QVariant>::key_iterator::operator*() const
.
Returns the current item’s key.
source§impl PartialEq<Ref<KeyIterator>> for KeyIterator
impl PartialEq<Ref<KeyIterator>> for KeyIterator
source§fn eq(&self, o: &Ref<KeyIterator>) -> bool
fn eq(&self, o: &Ref<KeyIterator>) -> bool
Returns true
if other points to the same item as this iterator; otherwise returns false
.
Calls C++ function: bool QMap<QString, QVariant>::key_iterator::operator==(QMap<QString, QVariant>::key_iterator o) const
.
Returns true
if other points to the same item as this iterator; otherwise returns false
.
See also operator!=().