[][src]Struct qt_core::q_map_of_int_q_variant::KeyIterator

#[repr(C)]
pub struct KeyIterator { /* fields omitted */ }

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.

Methods

impl KeyIterator[src]

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

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.

pub unsafe fn copy_from(
    &mut self,
    other: impl CastInto<Ref<KeyIterator>>
) -> MutRef<KeyIterator>
[src]

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.

pub unsafe fn dec(&mut self) -> MutRef<KeyIterator>[src]

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++().

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

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.

pub unsafe fn inc(&mut self) -> MutRef<KeyIterator>[src]

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--().

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

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.

pub unsafe fn indirection(&self) -> Ref<c_int>[src]

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.

pub unsafe fn new_0a() -> CppBox<KeyIterator>[src]

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.

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

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

pub unsafe fn new_copy(
    other: impl CastInto<Ref<KeyIterator>>
) -> CppBox<KeyIterator>
[src]

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.

pub unsafe fn struct_deref(&self) -> Ptr<c_int>[src]

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

impl PartialEq<Ref<KeyIterator>> for KeyIterator[src]

fn eq(&self, o: &Ref<KeyIterator>) -> bool[src]

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!=().

impl CppDeletable for KeyIterator[src]

unsafe fn delete(&mut self)[src]

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.

impl Decrement for KeyIterator[src]

type Output = MutRef<KeyIterator>

Output type.

unsafe fn dec(&mut self) -> MutRef<KeyIterator>[src]

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++().

impl Increment for KeyIterator[src]

type Output = MutRef<KeyIterator>

Output type.

unsafe fn inc(&mut self) -> MutRef<KeyIterator>[src]

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--().

impl Indirection for KeyIterator[src]

type Output = Ref<c_int>

Output type.

unsafe fn indirection(&self) -> Ref<c_int>[src]

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.

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]