File indexing completed on 2025-01-18 09:38:28
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
0055 typedef typename MapConfig::template
0056 intrusive_value_type<derivation_hook>::type value_type;
0057 typedef std::less<value_type> value_compare;
0058 typedef typename bi::make_set
0059 < value_type
0060 , bi::base_hook<derivation_hook>
0061 >::type index_t;
0062 };
0063 #endif
0064
0065
0066
0067
0068 template <class MapConfig>
0069 class iset_index
0070
0071 : public iset_index_aux<MapConfig>::index_t
0072 {
0073 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0074 typedef iset_index_aux<MapConfig> index_aux;
0075 typedef typename index_aux::index_t index_type;
0076 typedef typename MapConfig::
0077 intrusive_compare_key_type intrusive_compare_key_type;
0078 typedef typename MapConfig::char_type char_type;
0079 #endif
0080
0081 public:
0082 typedef typename index_type::iterator iterator;
0083 typedef typename index_type::const_iterator const_iterator;
0084 typedef typename index_type::insert_commit_data insert_commit_data;
0085 typedef typename index_type::value_type value_type;
0086
0087 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0088 private:
0089
0090 struct intrusive_key_value_less
0091 {
0092 bool operator()(const intrusive_compare_key_type &i, const value_type &b) const
0093 {
0094 std::size_t blen = b.name_length();
0095 return (i.m_len < blen) ||
0096 (i.m_len == blen &&
0097 std::char_traits<char_type>::compare
0098 (i.mp_str, b.name(), i.m_len) < 0);
0099 }
0100
0101 bool operator()(const value_type &b, const intrusive_compare_key_type &i) const
0102 {
0103 std::size_t blen = b.name_length();
0104 return (blen < i.m_len) ||
0105 (blen == i.m_len &&
0106 std::char_traits<char_type>::compare
0107 (b.name(), i.mp_str, i.m_len) < 0);
0108 }
0109 };
0110
0111 #endif
0112
0113 public:
0114
0115
0116
0117 iset_index(typename MapConfig::segment_manager_base *)
0118 : index_type()
0119 {}
0120
0121
0122
0123 void reserve(typename MapConfig::segment_manager_base::size_type)
0124 { }
0125
0126
0127 void shrink_to_fit()
0128 { }
0129
0130 iterator find(const intrusive_compare_key_type &key)
0131 { return index_type::find(key, intrusive_key_value_less()); }
0132
0133 const_iterator find(const intrusive_compare_key_type &key) const
0134 { return index_type::find(key, intrusive_key_value_less()); }
0135
0136 std::pair<iterator, bool>insert_check
0137 (const intrusive_compare_key_type &key, insert_commit_data &commit_data)
0138 { return index_type::insert_check(key, intrusive_key_value_less(), commit_data); }
0139 };
0140
0141 #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0142
0143
0144
0145 template<class MapConfig>
0146 struct is_intrusive_index
0147 <boost::interprocess::iset_index<MapConfig> >
0148 {
0149 static const bool value = true;
0150 };
0151 #endif
0152
0153 }
0154 }
0155
0156 #include <boost/interprocess/detail/config_end.hpp>
0157
0158 #endif