fix8  version 1.4.0
Open Source C++ FIX Framework
FIX8::GeneratedTable< Key, Val > Class Template Reference

Fast map for statically generated data types. Assumes table is sorted. Complexity is O(logN). More...

#include <f8types.hpp>

Public Types

using Pair = _pair< Key, Val >
 
using iterator = Pair *
 
using const_iterator = const Pair *
 

Public Member Functions

 GeneratedTable (const_iterator pairs, const size_t pairsz)
 Ctor. More...
 
const_iterator begin () const
 
const_iterator end () const
 
const Val & find_ref (const Key &key) const
 
const Val * find_ptr (const Key &key) const
 
const_iterator find_pair_ptr (const Key &key) const
 
const_iterator at (const size_t idx) const
 
size_t size () const
 

Private Member Functions

const_iterator _find (const Key &key) const
 

Private Attributes

const_iterator _pairs
 The actual data set. More...
 
const size_t _pairsz
 The number of elements in the data set. More...
 

Detailed Description

template<typename Key, typename Val>
class FIX8::GeneratedTable< Key, Val >

Fast map for statically generated data types. Assumes table is sorted. Complexity is O(logN).

Template Parameters
Keythe key
Valthe value

Definition at line 100 of file f8types.hpp.

Member Typedef Documentation

template<typename Key , typename Val >
using FIX8::GeneratedTable< Key, Val >::const_iterator = const Pair*

Definition at line 105 of file f8types.hpp.

template<typename Key , typename Val >
using FIX8::GeneratedTable< Key, Val >::iterator = Pair*

Definition at line 104 of file f8types.hpp.

template<typename Key , typename Val >
using FIX8::GeneratedTable< Key, Val >::Pair = _pair<Key, Val>

Definition at line 103 of file f8types.hpp.

Constructor & Destructor Documentation

template<typename Key , typename Val >
FIX8::GeneratedTable< Key, Val >::GeneratedTable ( const_iterator  pairs,
const size_t  pairsz 
)
inline

Ctor.

Definition at line 128 of file f8types.hpp.

129  : _pairs(pairs), _pairsz(pairsz) {}
const size_t _pairsz
The number of elements in the data set.
Definition: f8types.hpp:114
const_iterator _pairs
The actual data set.
Definition: f8types.hpp:111

Member Function Documentation

template<typename Key , typename Val >
const_iterator FIX8::GeneratedTable< Key, Val >::_find ( const Key &  key) const
inlineprivate

Find a key; complexity log2(N)+2

Parameters
keythe key to find
Returns
Pair * if found, 0 if not found

res != end && key >= res

Definition at line 119 of file f8types.hpp.

References FIX8::GeneratedTable< Key, Val >::begin(), FIX8::GeneratedTable< Key, Val >::end(), and FIX8::_pair< Key, Val >::Less().

Referenced by FIX8::GeneratedTable< Key, Val >::find_pair_ptr(), FIX8::GeneratedTable< Key, Val >::find_ptr(), and FIX8::GeneratedTable< Key, Val >::find_ref().

120  {
121  const_iterator res(std::lower_bound (begin(), end(), reinterpret_cast<const Pair&>(key), Pair::Less));
123  return res != end() && !Pair::Less(reinterpret_cast<const Pair&>(key), *res) ? res : nullptr;
124  }
const_iterator begin() const
Definition: f8types.hpp:133
const Pair * const_iterator
Definition: f8types.hpp:105
static bool Less(const _pair &p1, const _pair &p2)
Sort functor.
Definition: f8types.hpp:78
const_iterator end() const
Definition: f8types.hpp:137
template<typename Key , typename Val >
const_iterator FIX8::GeneratedTable< Key, Val >::at ( const size_t  idx) const
inline

Get the pair at index location

Parameters
idxof the pair to retrieve
Returns
pointer to pair or nullptr if not found

Definition at line 172 of file f8types.hpp.

Referenced by FIX8::F8MetaCntx::F8MetaCntx().

172 { return idx < _pairsz ? _pairs + idx : nullptr; }
const size_t _pairsz
The number of elements in the data set.
Definition: f8types.hpp:114
const_iterator _pairs
The actual data set.
Definition: f8types.hpp:111
template<typename Key , typename Val >
const_iterator FIX8::GeneratedTable< Key, Val >::begin ( ) const
inline

Get iterator to start of Pairs

Returns
pointer to first pair

Definition at line 133 of file f8types.hpp.

References FIX8::GeneratedTable< Key, Val >::_pairs.

Referenced by FIX8::GeneratedTable< Key, Val >::_find(), and FIX8::F8MetaCntx::F8MetaCntx().

133 { return _pairs; }
const_iterator _pairs
The actual data set.
Definition: f8types.hpp:111
template<typename Key , typename Val >
const_iterator FIX8::GeneratedTable< Key, Val >::end ( ) const
inline

Get iterator to last + 1 of Pairs

Returns
pointer to last + 1 pair

Definition at line 137 of file f8types.hpp.

References FIX8::GeneratedTable< Key, Val >::_pairsz.

Referenced by FIX8::GeneratedTable< Key, Val >::_find(), and FIX8::F8MetaCntx::F8MetaCntx().

137 { return _pairs + _pairsz; }
const size_t _pairsz
The number of elements in the data set.
Definition: f8types.hpp:114
const_iterator _pairs
The actual data set.
Definition: f8types.hpp:111
template<typename Key , typename Val >
const_iterator FIX8::GeneratedTable< Key, Val >::find_pair_ptr ( const Key &  key) const
inline

Find a key pair record (pointer).

Parameters
keythe key to find
Returns
key/value pair (pointer) or 0 if not found

Definition at line 163 of file f8types.hpp.

References FIX8::GeneratedTable< Key, Val >::_find().

164  {
165  const_iterator res(_find(key));
166  return res ? res : nullptr;
167  }
const_iterator _find(const Key &key) const
Definition: f8types.hpp:119
const Pair * const_iterator
Definition: f8types.hpp:105
template<typename Key , typename Val >
const Val* FIX8::GeneratedTable< Key, Val >::find_ptr ( const Key &  key) const
inline

Find a key (pointer).

Parameters
keythe key to find
Returns
value found (pointer) or 0 if not found

Definition at line 154 of file f8types.hpp.

References FIX8::GeneratedTable< Key, Val >::_find(), and FIX8::_pair< Key, Val >::_value.

Referenced by FIX8::Session::create_msg(), FIX8::Message::factory(), and FIX8::F8MetaCntx::find_bme().

155  {
156  const_iterator res(_find(key));
157  return res ? &res->_value : nullptr;
158  }
const_iterator _find(const Key &key) const
Definition: f8types.hpp:119
const Pair * const_iterator
Definition: f8types.hpp:105
template<typename Key , typename Val >
const Val& FIX8::GeneratedTable< Key, Val >::find_ref ( const Key &  key) const
inline

Find a key (reference). If not found, throw InvalidMetadata. Ye Olde Binary Chop

Parameters
keythe key to find
Returns
value found (reference)

Definition at line 143 of file f8types.hpp.

References FIX8::GeneratedTable< Key, Val >::_find(), and FIX8::_pair< Key, Val >::_value.

144  {
145  const_iterator res(_find(key));
146  if (res)
147  return res->_value;
148  throw InvalidMetadata<Key>(key);
149  }
const_iterator _find(const Key &key) const
Definition: f8types.hpp:119
const Pair * const_iterator
Definition: f8types.hpp:105
template<typename Key , typename Val >
size_t FIX8::GeneratedTable< Key, Val >::size ( ) const
inline

Get the number of elements in the data set.

Returns
number of elements

Definition at line 176 of file f8types.hpp.

References FIX8::GeneratedTable< Key, Val >::_pairsz.

Referenced by FIX8::F8MetaCntx::F8MetaCntx().

176 { return _pairsz; }
const size_t _pairsz
The number of elements in the data set.
Definition: f8types.hpp:114

Member Data Documentation

template<typename Key , typename Val >
const_iterator FIX8::GeneratedTable< Key, Val >::_pairs
private

The actual data set.

Definition at line 111 of file f8types.hpp.

Referenced by FIX8::GeneratedTable< Key, Val >::begin().

template<typename Key , typename Val >
const size_t FIX8::GeneratedTable< Key, Val >::_pairsz
private

The number of elements in the data set.

Definition at line 114 of file f8types.hpp.

Referenced by FIX8::GeneratedTable< Key, Val >::end(), and FIX8::GeneratedTable< Key, Val >::size().


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