File indexing completed on 2025-01-18 09:38:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_INTERPROCESS_UNORDERED_MAP_INDEX_HPP
0012 #define BOOST_INTERPROCESS_UNORDERED_MAP_INDEX_HPP
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017 #
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 # pragma once
0020 #endif
0021
0022 #include <boost/interprocess/detail/config_begin.hpp>
0023 #include <boost/interprocess/detail/workaround.hpp>
0024
0025 #include <boost/intrusive/detail/minimal_pair_header.hpp>
0026 #include <boost/unordered_map.hpp>
0027 #include <boost/interprocess/detail/utilities.hpp>
0028 #include <boost/interprocess/allocators/private_adaptive_pool.hpp>
0029
0030 #include <boost/intrusive/detail/minimal_pair_header.hpp> //std::pair
0031 #include <boost/intrusive/detail/minimal_less_equal_header.hpp> //std::less
0032
0033
0034
0035
0036
0037 namespace boost {
0038 namespace interprocess {
0039
0040 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0041
0042
0043
0044 template <class MapConfig>
0045 struct unordered_map_index_aux
0046 {
0047 typedef typename MapConfig::key_type key_type;
0048 typedef typename MapConfig::mapped_type mapped_type;
0049 typedef std::equal_to<key_type> key_equal;
0050 typedef std::pair<const key_type, mapped_type> value_type;
0051 typedef private_adaptive_pool
0052 <value_type,
0053 typename MapConfig::
0054 segment_manager_base> allocator_type;
0055 struct hasher
0056 {
0057 typedef key_type argument_type;
0058 typedef std::size_t result_type;
0059
0060 std::size_t operator()(const key_type &val) const
0061 {
0062 typedef typename key_type::char_type char_type;
0063 const char_type *beg = ipcdetail::to_raw_pointer(val.mp_str),
0064 *end = beg + val.m_len;
0065 return boost::hash_range(beg, end);
0066 }
0067 };
0068 typedef unordered_map<key_type, mapped_type, hasher,
0069 key_equal, allocator_type> index_t;
0070 };
0071
0072 #endif
0073
0074
0075
0076 template <class MapConfig>
0077 class unordered_map_index
0078
0079 : public unordered_map_index_aux<MapConfig>::index_t
0080 {
0081 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0082 typedef unordered_map_index_aux<MapConfig> index_aux;
0083 typedef typename index_aux::index_t base_type;
0084 typedef typename
0085 MapConfig::segment_manager_base segment_manager_base;
0086 #endif
0087
0088 public:
0089
0090
0091 unordered_map_index(segment_manager_base *segment_mngr)
0092 : base_type(0,
0093 typename index_aux::hasher(),
0094 typename index_aux::key_equal(),
0095 segment_mngr){}
0096
0097
0098
0099 void reserve(typename segment_manager_base::size_type n)
0100 { base_type::rehash(n); }
0101
0102
0103
0104 void shrink_to_fit()
0105 { base_type::rehash(base_type::size()); }
0106 };
0107
0108 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0109
0110
0111
0112
0113 template<class MapConfig>
0114 struct is_node_index
0115 <boost::interprocess::unordered_map_index<MapConfig> >
0116 {
0117 static const bool value = true;
0118 };
0119 #endif
0120
0121 }}
0122
0123 #include <boost/interprocess/detail/config_end.hpp>
0124
0125 #endif