PIP 5.6.1
Platform-Independent Primitives
Public Member Functions | List of all members
PIMapIteratorConst< Key, T > Class Template Reference

Java-style iterator for PIMap. More...

#include <pimap.h>

Public Member Functions

const Key & key () const
 Returns current key. More...
 
const T & value () const
 Returns current value. More...
 
bool hasNext () const
 Returns true if iterator can jump to next entry. More...
 
bool next ()
 Jump to next entry and return true if new position is valid. More...
 
void reset ()
 Reset iterator to initial position. More...
 

Detailed Description

template<typename Key, typename T>
class PIMapIteratorConst< Key, T >

Java-style iterator for PIMap.

Provides sequential read-only access to keys and values in PIMap. Use the constructor directly or call PIMap::makeIterator().

m[1] = "one";
m[2] = "two";
m[4] = "four";
auto it = m.makeIterator();
while (it.next()) {
piCout << it.key() << it.value();
}
// 1 one
// 2 two
// 4 four
#define piCout
Definition: picout.h:36

Member Function Documentation

◆ key()

template<typename Key , typename T >
const Key & PIMapIteratorConst< Key, T >::key ( ) const
inline

Returns current key.

See also
value()

◆ value()

template<typename Key , typename T >
const T & PIMapIteratorConst< Key, T >::value ( ) const
inline

Returns current value.

See also
key()

◆ hasNext()

template<typename Key , typename T >
bool PIMapIteratorConst< Key, T >::hasNext ( ) const
inline

Returns true if iterator can jump to next entry.

See also
next()

◆ next()

template<typename Key , typename T >
bool PIMapIteratorConst< Key, T >::next ( )
inline

Jump to next entry and return true if new position is valid.

See also
hasNext(), reset()

◆ reset()

template<typename Key , typename T >
void PIMapIteratorConst< Key, T >::reset ( )
inline

Reset iterator to initial position.

See also
next()