File indexing completed on 2025-12-15 09:53:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_INTERPROCESS_ISET_INDEX_HPP
0012 #define BOOST_INTERPROCESS_ISET_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/interprocess/detail/utilities.hpp>
0027 #include <boost/intrusive/detail/minimal_pair_header.hpp> //std::pair
0028 #include <boost/intrusive/detail/minimal_less_equal_header.hpp> //std::less
0029 #include <boost/container/detail/minimal_char_traits_header.hpp> //std::char_traits
0030 #include <boost/intrusive/set.hpp>
0031
0032
0033
0034
0035
0036 namespace boost {
0037 namespace interprocess {
0038
0039 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0040
0041
0042 template <class MapConfig>
0043 struct iset_index_aux
0044 {
0045 typedef typename
0046 MapConfig::segment_manager_base segment_manager_base;
0047
0048 typedef typename
0049 segment_manager_base::void_pointer void_pointer;
0050 typedef typename bi::make_set_base_hook
0051 < bi::void_pointer<void_pointer>
0052 , bi::optimize_size<true>
0053 >::type derivation_hook;
0054 typedef typename MapConfig::char_type char_type;
0055 typedef typename MapConfig::template
0056 intrusive_value_type<derivation_hook>::type value_type;
0057
0058 typedef typename MapConfig::compare_key_type compare_key_type;
0059
0060 struct less_function
0061 {
0062 bool operator()(const compare_key_type&i, const value_type &b) const
0063 {
0064 std::size_t blen = b.name_length();
0065 return (i.m_len < blen) ||
0066 (i.m_len == blen &&
0067 std::char_traits<char_type>::compare
0068 (i.mp_str, b.name(), i.m_len) < 0);
0069 }
0070
0071 bool operator()(const value_type &b, const compare_key_type&i) const
0072 {
0073 std::size_t blen = b.name_length();
0074 return (blen < i.m_len) ||
0075 (blen == i.m_len &&
0076 std::char_traits<char_type>::compare
0077 (b.name(), i.mp_str, i.m_len) < 0);
0078 }
0079
0080 bool operator()(const value_type& a, const value_type& b) const
0081 {
0082 std::size_t alen = a.name_length();
0083 std::size_t blen = b.name_length();
0084 return (alen < blen) ||
0085 (alen == blen &&
0086 std::char_traits<char_type>::compare
0087 (a.name(), b.name(), alen) < 0);
0088 }
0089 };
0090
0091 typedef std::less<value_type> value_compare;
0092 typedef typename bi::make_set
0093 < value_type
0094 , bi::base_hook<derivation_hook>
0095 , bi::compare<less_function>
0096 >::type index_t;
0097 };
0098 #endif
0099
0100
0101
0102
0103 template <class MapConfig>
0104 class iset_index
0105
0106 : private iset_index_aux<MapConfig>::index_t
0107 {
0108 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0109 typedef iset_index_aux<MapConfig> index_aux;
0110 typedef typename index_aux::index_t index_type;
0111 typedef typename MapConfig::char_type char_type;
0112 typedef typename index_aux::less_function less_function;
0113 #endif
0114
0115 public:
0116 typedef typename index_type::iterator iterator;
0117 typedef typename index_type::const_iterator const_iterator;
0118 typedef typename index_type::insert_commit_data insert_commit_data;
0119 typedef typename index_type::value_type value_type;
0120 typedef typename MapConfig::compare_key_type compare_key_type;
0121 typedef value_type index_data_t;
0122
0123 public:
0124
0125 using index_type::begin;
0126 using index_type::end;
0127 using index_type::size;
0128 using index_type::erase;
0129
0130
0131
0132 iset_index(typename MapConfig::segment_manager_base *)
0133 : index_type()
0134 {}
0135
0136
0137
0138 void reserve(typename MapConfig::segment_manager_base::size_type)
0139 { }
0140
0141
0142 void shrink_to_fit()
0143 { }
0144
0145 iterator find(const compare_key_type&key)
0146 { return index_type::find(key, less_function()); }
0147
0148 const_iterator find(const compare_key_type&key) const
0149 { return index_type::find(key, less_function()); }
0150
0151 std::pair<iterator, bool>insert_check
0152 (const compare_key_type &key, insert_commit_data &commit_data)
0153 { return index_type::insert_check(key, less_function(), commit_data); }
0154
0155 iterator insert_commit
0156 (const compare_key_type &, void*, index_data_t&v, insert_commit_data& commit_data)
0157 { return index_type::insert_commit(v, commit_data); }
0158 };
0159
0160 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0161
0162
0163
0164 template<class MapConfig>
0165 struct is_intrusive_index
0166 <boost::interprocess::iset_index<MapConfig> >
0167 {
0168 static const bool value = true;
0169 };
0170 #endif
0171
0172 }
0173 }
0174
0175 #include <boost/interprocess/detail/config_end.hpp>
0176
0177 #endif