Belle II Software development
KeyValBox< KeyType, ValueType > Class Template Reference

Minimal container storing a pair of < KeyType, ValueType> More...

#include <KeyValBox.h>

Public Types

using BoxEntry = std::pair<KeyType, ValueType>
 typedef for readable entry-type
 
using Iterator = typename std::vector<BoxEntry>::iterator
 typedef for more readable iterator-type
 
using ConstIterator = typename std::vector<BoxEntry>::const_iterator
 typedef for more readable iterator-type
 

Public Member Functions

ValueType * find (const KeyType &aKey)
 for given key a pointer to the value is returned.
 
void push_back (std::pair< KeyType, ValueType > &newPair)
 push_back for new pair given
 
void push_back (std::pair< KeyType, ValueType > newPair)
 push_back for new pair given
 
Iterator begin ()
 returns iterator for container: begin
 
ConstIterator begin () const
 returns iterator for container: begin
 
Iterator end ()
 returns iterator for container: end
 
ConstIterator end () const
 returns iterator for container: end
 
unsigned int size () const
 returns number of entries in container:
 

Protected Attributes

std::vector< std::pair< KeyType, ValueType > > m_container
 the container containing the keys and values
 

Detailed Description

template<class KeyType, class ValueType>
class Belle2::KeyValBox< KeyType, ValueType >

Minimal container storing a pair of < KeyType, ValueType>

Definition at line 24 of file KeyValBox.h.

Member Typedef Documentation

◆ BoxEntry

template<class KeyType, class ValueType>
using BoxEntry = std::pair<KeyType, ValueType>

typedef for readable entry-type

Definition at line 33 of file KeyValBox.h.

◆ ConstIterator

template<class KeyType, class ValueType>
using ConstIterator = typename std::vector<BoxEntry>::const_iterator

typedef for more readable iterator-type

Definition at line 41 of file KeyValBox.h.

◆ Iterator

template<class KeyType, class ValueType>
using Iterator = typename std::vector<BoxEntry>::iterator

typedef for more readable iterator-type

Definition at line 37 of file KeyValBox.h.

Member Function Documentation

◆ begin() [1/2]

template<class KeyType, class ValueType>
Iterator begin ( )
inline

returns iterator for container: begin

Definition at line 66 of file KeyValBox.h.

66{ return m_container.begin(); }

◆ begin() [2/2]

template<class KeyType, class ValueType>
ConstIterator begin ( ) const
inline

returns iterator for container: begin

Definition at line 70 of file KeyValBox.h.

70{ return m_container.begin(); }

◆ end() [1/2]

template<class KeyType, class ValueType>
Iterator end ( )
inline

returns iterator for container: end

Definition at line 74 of file KeyValBox.h.

74{ return m_container.end(); }

◆ end() [2/2]

template<class KeyType, class ValueType>
ConstIterator end ( ) const
inline

returns iterator for container: end

Definition at line 78 of file KeyValBox.h.

78{ return m_container.end(); }

◆ find()

template<class KeyType, class ValueType>
ValueType * find ( const KeyType & aKey)
inline

for given key a pointer to the value is returned.

If key was invalid, a nullptr-ptr will be returned

Definition at line 45 of file KeyValBox.h.

46 {
47 Iterator foundPos = std::find_if(
48 m_container.begin(),
49 m_container.end(),
50 [&](const BoxEntry & entry) -> bool
51 { return entry.first == aKey; }
52 );
53 return (foundPos == m_container.end() ? nullptr : &foundPos->second);
54 }
map< unsigned, size_t >::const_iterator Iterator
Iteratior for m_map.

◆ push_back() [1/2]

template<class KeyType, class ValueType>
void push_back ( std::pair< KeyType, ValueType > & newPair)
inline

push_back for new pair given

Definition at line 58 of file KeyValBox.h.

58{ m_container.push_back(newPair); }

◆ push_back() [2/2]

template<class KeyType, class ValueType>
void push_back ( std::pair< KeyType, ValueType > newPair)
inline

push_back for new pair given

Definition at line 62 of file KeyValBox.h.

62{ m_container.push_back(newPair); }

◆ size()

template<class KeyType, class ValueType>
unsigned int size ( ) const
inline

returns number of entries in container:

Definition at line 82 of file KeyValBox.h.

82{ return m_container.size(); }

Member Data Documentation

◆ m_container

template<class KeyType, class ValueType>
std::vector<std::pair<KeyType, ValueType> > m_container
protected

the container containing the keys and values

Definition at line 28 of file KeyValBox.h.


The documentation for this class was generated from the following file: