#[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<int, QVariant>::key_iterator.

C++ documentation:

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

source

pub unsafe fn base(&self) -> CppBox<ConstIterator>

Returns the underlying const_iterator this key_iterator is based on.

Calls C++ function: QMap<int, QVariant>::const_iterator QMap<int, QVariant>::key_iterator::base() const.

C++ documentation:

Returns the underlying const_iterator this key_iterator is based on.

source

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<int, QVariant>::key_iterator& QMap<int, QVariant>::key_iterator::operator=(const QMap<int, QVariant>::key_iterator& other).

C++ documentation:

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

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<int, QVariant>::key_iterator& QMap<int, QVariant>::key_iterator::operator--().

C++ documentation:

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

pub unsafe fn dec_postfix(&self, arg1: c_int) -> CppBox<KeyIterator>

This is an overloaded function.

Calls C++ function: QMap<int, QVariant>::key_iterator QMap<int, QVariant>::key_iterator::operator--(int arg1).

C++ documentation:

This is an overloaded function.

The postfix -- operator (i--) makes the preceding item current and returns an iterator pointing to the previous item.

source

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<int, QVariant>::key_iterator& QMap<int, QVariant>::key_iterator::operator++().

C++ documentation:

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

pub unsafe fn inc_postfix(&self, arg1: c_int) -> CppBox<KeyIterator>

This is an overloaded function.

Calls C++ function: QMap<int, QVariant>::key_iterator QMap<int, QVariant>::key_iterator::operator++(int arg1).

C++ documentation:

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.

source

pub unsafe fn indirection(&self) -> *const c_int

Returns the current item's key.

Calls C++ function: const int& QMap<int, QVariant>::key_iterator::operator*() const.

C++ documentation:

Returns the current item’s key.

source

pub unsafe fn new_0a() -> CppBox<KeyIterator>

Default constructs an instance of key_iterator.

Calls C++ function: [constructor] void QMap<int, QVariant>::key_iterator::key_iterator().

C++ documentation:

Default constructs an instance of key_iterator.

source

pub unsafe fn new_1a( o: impl CastInto<Ref<ConstIterator>> ) -> CppBox<KeyIterator>

Calls C++ function: [constructor] void QMap<int, QVariant>::key_iterator::key_iterator(QMap<int, QVariant>::const_iterator o).

source

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<int, QVariant>::key_iterator::key_iterator(const QMap<int, QVariant>::key_iterator& other).

C++ documentation:

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

pub unsafe fn struct_deref(&self) -> *const c_int

Returns a pointer to the current item's key.

Calls C++ function: const int* QMap<int, QVariant>::key_iterator::operator->() const.

C++ documentation:

Returns a pointer to the current item’s key.

Trait Implementations§

source§

impl CppDeletable for KeyIterator

source§

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<int, QVariant>::key_iterator::~key_iterator().

C++ documentation:

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

source§

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<int, QVariant>::key_iterator& QMap<int, QVariant>::key_iterator::operator--().

C++ documentation:

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>

Output type.
source§

impl Increment for KeyIterator

source§

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<int, QVariant>::key_iterator& QMap<int, QVariant>::key_iterator::operator++().

C++ documentation:

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>

Output type.
source§

impl Indirection for KeyIterator

source§

unsafe fn indirection(&self) -> *const c_int

Returns the current item's key.

Calls C++ function: const int& QMap<int, QVariant>::key_iterator::operator*() const.

C++ documentation:

Returns the current item’s key.

§

type Output = *const i32

Output type.
source§

impl PartialEq<Ref<KeyIterator>> for KeyIterator

source§

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<int, QVariant>::key_iterator::operator==(QMap<int, QVariant>::key_iterator o) const.

C++ documentation:

Returns true if other points to the same item as this iterator; otherwise returns false.

See also operator!=().

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.