#[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<Qt::GestureType, QWidget*>::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<Qt::GestureType, QWidget*>::const_iterator QMap<Qt::GestureType, QWidget*>::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<Qt::GestureType, QWidget*>::key_iterator& QMap<Qt::GestureType, QWidget*>::key_iterator::operator=(const QMap<Qt::GestureType, QWidget*>::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<Qt::GestureType, QWidget*>::key_iterator& QMap<Qt::GestureType, QWidget*>::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<Qt::GestureType, QWidget*>::key_iterator QMap<Qt::GestureType, QWidget*>::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<Qt::GestureType, QWidget*>::key_iterator& QMap<Qt::GestureType, QWidget*>::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<Qt::GestureType, QWidget*>::key_iterator QMap<Qt::GestureType, QWidget*>::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) -> *const GestureType
pub unsafe fn indirection(&self) -> *const GestureType
Returns the current item's key.
Calls C++ function: const Qt::GestureType& QMap<Qt::GestureType, QWidget*>::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<Qt::GestureType, QWidget*>::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<Qt::GestureType, QWidget*>::key_iterator::key_iterator(QMap<Qt::GestureType, QWidget*>::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<Qt::GestureType, QWidget*>::key_iterator::key_iterator(const QMap<Qt::GestureType, QWidget*>::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) -> *const GestureType
pub unsafe fn struct_deref(&self) -> *const GestureType
Returns a pointer to the current item's key.
Calls C++ function: const Qt::GestureType* QMap<Qt::GestureType, QWidget*>::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<Qt::GestureType, QWidget*>::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<Qt::GestureType, QWidget*>::key_iterator& QMap<Qt::GestureType, QWidget*>::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++().
Source§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<Qt::GestureType, QWidget*>::key_iterator& QMap<Qt::GestureType, QWidget*>::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--().
Source§type Output = Ref<KeyIterator>
type Output = Ref<KeyIterator>
Source§impl Indirection for KeyIterator
impl Indirection for KeyIterator
Source§unsafe fn indirection(&self) -> *const GestureType
unsafe fn indirection(&self) -> *const GestureType
Returns the current item's key.
Calls C++ function: const Qt::GestureType& QMap<Qt::GestureType, QWidget*>::key_iterator::operator*() const.
Returns the current item’s key.
Source§type Output = *const GestureType
type Output = *const GestureType
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<Qt::GestureType, QWidget*>::key_iterator::operator==(QMap<Qt::GestureType, QWidget*>::key_iterator o) const.
Returns true if other points to the same item as this iterator; otherwise returns false.
See also operator!=().