Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JSTDToolkit.hh
Go to the documentation of this file.
1#ifndef __JLANG__JSTDTOOLKIT__
2#define __JLANG__JSTDTOOLKIT__
3
4#include "JLang/JSTDTypes.hh"
5
6
7/**
8 * \author mdejong
9 */
10
11namespace JLANG {}
12namespace JPP { using namespace JLANG; }
13
14namespace JLANG {
15
16 /**
17 * Get value in map.
18 *
19 * The value in the map at the given key is returned if present else the default value.
20 *
21 * \param map map
22 * \param key key
23 * \param value default value
24 * \return value
25 */
26 template<class JKey_t, class JValue_t, class JComparator_t, class JAllocator_t>
27 inline const JValue_t& getValue(const std::map<JKey_t, JValue_t, JComparator_t, JAllocator_t>& map, const JKey_t& key, const JValue_t& value)
28 {
30
31 if (i != map.end())
32 return i->second;
33 else
34 return value;
35 }
36
37
38 /**
39 * Put end marker.
40 *
41 * The end marker is put at the end but within the capacity of the given vector whilst its size is maintained.
42 *
43 * \param buffer buffer
44 * \param value end marker
45 */
46 template<class JElement_t, class JAllocator_t>
47 inline void putEndMarker(std::vector<JElement_t, JAllocator_t>& buffer, const JElement_t& value)
48 {
49 if (buffer.capacity() <= buffer.size()) {
50 buffer.reserve(buffer.size() + 1);
51 }
52
53 *(buffer.end()) = value;
54 }
55}
56
57#endif
Forward declarations of STD containers.
const char * map
Definition elog.cc:87
Auxiliary classes and methods for language specific functionality.
void putEndMarker(std::vector< JElement_t, JAllocator_t > &buffer, const JElement_t &value)
Put end marker.
const JValue_t & getValue(const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &map, const JKey_t &key, const JValue_t &value)
Get value in map.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).