36 #ifndef FIX8_TYPES_HPP_
37 #define FIX8_TYPES_HPP_
48 #if defined FIX8_USE_SINGLE_PRECISION
68 template<
typename Key,
typename Val>
83 template<
typename Val>
89 const char *
first()
const {
return _key; }
90 const Val&
second()
const {
return _value; }
99 template<
typename Key,
typename Val>
123 return res !=
end() && !
Pair::Less(reinterpret_cast<const Pair&>(key), *res) ? res :
nullptr;
129 : _pairs(pairs), _pairsz(pairsz) {}
157 return res ? &res->
_value :
nullptr;
166 return res ? res :
nullptr;
172 const_iterator at(
const size_t idx)
const {
return idx < _pairsz ? _pairs + idx :
nullptr; }
185 template<
typename K,
typename T,
typename Comp>
191 using result = std::pair<iterator, bool>;
209 const size_t val(sz * res / 100);
210 return val ? val : 1;
219 _sz(sz), _rsz(_sz +
calc_reserve(_sz, _reserve)), _arr(new T[_rsz])
220 { memcpy(_arr, arr_start, _sz *
sizeof(T)); }
225 _sz(from._sz), _rsz(from._rsz), _arr(from._arr ? new T[_rsz] : 0)
226 {
if (_arr) memcpy(_arr, from.
_arr, _sz *
sizeof(T)); }
232 _sz(sz), _rsz(_sz +
calc_reserve(_sz, _reserve)), _arr() {}
243 const internal_result res(std::equal_range (_arr, _arr + _sz, what, Comp()));
244 answer = res.first != res.second;
265 return res.first != res.second ? res.first :
end();
278 internal_result res(std::equal_range (_arr, _arr + _sz, what, Comp()));
279 return res.first != res.second ? res.first :
end();
295 memcpy(_arr, what,
sizeof(T));
297 return result(_arr,
true);
307 memmove(where + 1, where, (
end() - where) *
sizeof(T));
308 memcpy(where, what,
sizeof(T));
313 const size_t wptr(where - _arr);
315 memcpy(new_arr, _arr,
sizeof(T) * wptr);
316 memcpy(new_arr + wptr, what,
sizeof(T));
317 memcpy(new_arr + wptr + 1, where, (
end() - where) *
sizeof(T));
322 return result(where,
true);
330 {
return what_end - what_begin; }
351 bool empty()
const {
return _sz == 0; }
378 template<
typename T,
typename... args>
struct Type2Type {};
386 #endif // F8_TYPES_HPP_
const_iterator find_pair_ptr(const Key &key) const
const_iterator begin() const
static bool Less(const _pair &p1, const _pair &p2)
Sort functor.
const Val & second() const
null_insert & operator<<(const T &)
const_iterator begin() const
static size_t calc_reserve(size_t sz, size_t res)
std::pair< const_iterator, const_iterator > const_internal_result
Pair abstraction for use with GeneratedTable.
std::pair< iterator, iterator > internal_result
iterator find(const K key)
const_iterator _find(const Key &key) const
void insert(const_iterator what_begin, const_iterator what_end)
ProcessModel
Supported session process models.
iterator find(const K key, bool &answer)
const_iterator end() const
result insert(const_iterator what)
const Val & second() const
Type2Type idiom. Variadic template version. Kudos to Andrei Alexandrescu.
#define FIX8_RESERVE_PERCENT
std::pair< iterator, bool > result
const size_t _pairsz
The number of elements in the data set.
const char * first() const
const unsigned char default_assignment_separator('=')
default FIX assignment separator (=)
const_iterator find(const K key) const
presorted_set(const presorted_set &from)
iterator find(const T what, bool &answer)
const unsigned char default_field_separator(0x1)
default FIX field separator (^A)
const_iterator find(const T what) const
presorted_set(const_iterator arr_start, const size_t sz, const size_t reserve=FIX8_RESERVE_PERCENT)
const_iterator _pairs
The actual data set.
const_iterator at(const size_t idx) const
const Val & find_ref(const Key &key) const
const_iterator at(const size_t idx) const
static size_t distance(const_iterator what_begin, const_iterator what_end)
GeneratedTable(const_iterator pairs, const size_t pairsz)
Ctor.
static bool Less(const _pair &p1, const _pair &p2)
Sort functor.
const Val * find_ptr(const Key &key) const
Template provides insert operator that inserts nothing.
const Key & first() const
Fast map for statically generated data types. Assumes table is sorted. Complexity is O(logN)...
const_iterator end() const
presorted_set(const size_t sz=0, const size_t reserve=FIX8_RESERVE_PERCENT)
iterator find(const T what)