ord_index_ops.hpp
Go to the documentation of this file.
1 /* Copyright 2003-2014 Joaquin M Lopez Munoz.
2  * Distributed under the Boost Software License, Version 1.0.
3  * (See accompanying file LICENSE_1_0.txt or copy at
4  * http://www.boost.org/LICENSE_1_0.txt)
5  *
6  * See http://www.boost.org/libs/multi_index for library home page.
7  *
8  * The internal implementation of red-black trees is based on that of SGI STL
9  * stl_tree.h file:
10  *
11  * Copyright (c) 1996,1997
12  * Silicon Graphics Computer Systems, Inc.
13  *
14  * Permission to use, copy, modify, distribute and sell this software
15  * and its documentation for any purpose is hereby granted without fee,
16  * provided that the above copyright notice appear in all copies and
17  * that both that copyright notice and this permission notice appear
18  * in supporting documentation. Silicon Graphics makes no
19  * representations about the suitability of this software for any
20  * purpose. It is provided "as is" without express or implied warranty.
21  *
22  *
23  * Copyright (c) 1994
24  * Hewlett-Packard Company
25  *
26  * Permission to use, copy, modify, distribute and sell this software
27  * and its documentation for any purpose is hereby granted without fee,
28  * provided that the above copyright notice appear in all copies and
29  * that both that copyright notice and this permission notice appear
30  * in supporting documentation. Hewlett-Packard Company makes no
31  * representations about the suitability of this software for any
32  * purpose. It is provided "as is" without express or implied warranty.
33  *
34  */
35 
36 #ifndef BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_OPS_HPP
37 #define BOOST_MULTI_INDEX_DETAIL_ORD_INDEX_OPS_HPP
38 
39 #if defined(_MSC_VER)
40 #pragma once
41 #endif
42 
43 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
44 #include <boost/mpl/and.hpp>
46 #include <utility>
47 
48 namespace boost{
49 
50 namespace multi_index{
51 
52 namespace detail{
53 
54 /* Common code for index memfuns having templatized and
55  * non-templatized versions.
56  * Implementation note: When CompatibleKey is consistently promoted to
57  * KeyFromValue::result_type for comparison, the promotion is made once in
58  * advance to increase efficiency.
59  */
60 
61 template<
62  typename Node,typename KeyFromValue,
63  typename CompatibleKey,typename CompatibleCompare
64 >
65 inline Node* ordered_index_find(
66  Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
67  const CompatibleCompare& comp)
68 {
69  typedef typename KeyFromValue::result_type key_type;
70 
71  return ordered_index_find(
72  top,y,key,x,comp,
73  mpl::and_<
76 }
77 
78 template<
79  typename Node,typename KeyFromValue,
80  typename CompatibleCompare
81 >
82 inline Node* ordered_index_find(
83  Node* top,Node* y,const KeyFromValue& key,
85  const CompatibleCompare& comp,mpl::true_)
86 {
87  return ordered_index_find(top,y,key,x,comp,mpl::false_());
88 }
89 
90 template<
91  typename Node,typename KeyFromValue,
92  typename CompatibleKey,typename CompatibleCompare
93 >
94 inline Node* ordered_index_find(
95  Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
96  const CompatibleCompare& comp,mpl::false_)
97 {
98  Node* y0=y;
99 
100  while (top){
101  if(!comp(key(top->value()),x)){
102  y=top;
103  top=Node::from_impl(top->left());
104  }
105  else top=Node::from_impl(top->right());
106  }
107 
108  return (y==y0||comp(x,key(y->value())))?y0:y;
109 }
110 
111 template<
112  typename Node,typename KeyFromValue,
113  typename CompatibleKey,typename CompatibleCompare
114 >
116  Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
117  const CompatibleCompare& comp)
118 {
119  typedef typename KeyFromValue::result_type key_type;
120 
122  top,y,key,x,comp,
124 }
125 
126 template<
127  typename Node,typename KeyFromValue,
128  typename CompatibleCompare
129 >
131  Node* top,Node* y,const KeyFromValue& key,
133  const CompatibleCompare& comp,mpl::true_)
134 {
135  return ordered_index_lower_bound(top,y,key,x,comp,mpl::false_());
136 }
137 
138 template<
139  typename Node,typename KeyFromValue,
140  typename CompatibleKey,typename CompatibleCompare
141 >
143  Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
144  const CompatibleCompare& comp,mpl::false_)
145 {
146  while(top){
147  if(!comp(key(top->value()),x)){
148  y=top;
149  top=Node::from_impl(top->left());
150  }
151  else top=Node::from_impl(top->right());
152  }
153 
154  return y;
155 }
156 
157 template<
158  typename Node,typename KeyFromValue,
159  typename CompatibleKey,typename CompatibleCompare
160 >
162  Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
163  const CompatibleCompare& comp)
164 {
165  typedef typename KeyFromValue::result_type key_type;
166 
168  top,y,key,x,comp,
170 }
171 
172 template<
173  typename Node,typename KeyFromValue,
174  typename CompatibleCompare
175 >
177  Node* top,Node* y,const KeyFromValue& key,
179  const CompatibleCompare& comp,mpl::true_)
180 {
181  return ordered_index_upper_bound(top,y,key,x,comp,mpl::false_());
182 }
183 
184 template<
185  typename Node,typename KeyFromValue,
186  typename CompatibleKey,typename CompatibleCompare
187 >
189  Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
190  const CompatibleCompare& comp,mpl::false_)
191 {
192  while(top){
193  if(comp(x,key(top->value()))){
194  y=top;
195  top=Node::from_impl(top->left());
196  }
197  else top=Node::from_impl(top->right());
198  }
199 
200  return y;
201 }
202 
203 template<
204  typename Node,typename KeyFromValue,
205  typename CompatibleKey,typename CompatibleCompare
206 >
207 inline std::pair<Node*,Node*> ordered_index_equal_range(
208  Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
209  const CompatibleCompare& comp)
210 {
211  typedef typename KeyFromValue::result_type key_type;
212 
214  top,y,key,x,comp,
215  mpl::and_<
218 }
219 
220 template<
221  typename Node,typename KeyFromValue,
222  typename CompatibleCompare
223 >
224 inline std::pair<Node*,Node*> ordered_index_equal_range(
225  Node* top,Node* y,const KeyFromValue& key,
227  const CompatibleCompare& comp,mpl::true_)
228 {
229  return ordered_index_equal_range(top,y,key,x,comp,mpl::false_());
230 }
231 
232 template<
233  typename Node,typename KeyFromValue,
234  typename CompatibleKey,typename CompatibleCompare
235 >
236 inline std::pair<Node*,Node*> ordered_index_equal_range(
237  Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
238  const CompatibleCompare& comp,mpl::false_)
239 {
240  while(top){
241  if(comp(key(top->value()),x)){
242  top=Node::from_impl(top->right());
243  }
244  else if(comp(x,key(top->value()))){
245  y=top;
246  top=Node::from_impl(top->left());
247  }
248  else{
249  return std::pair<Node*,Node*>(
251  Node::from_impl(top->left()),top,key,x,comp,mpl::false_()),
253  Node::from_impl(top->right()),y,key,x,comp,mpl::false_()));
254  }
255  }
256 
257  return std::pair<Node*,Node*>(y,y);
258 }
259 
260 } /* namespace multi_index::detail */
261 
262 } /* namespace multi_index */
263 
264 } /* namespace boost */
265 
266 #endif
false_
bool_< false > false_
Definition: bool_fwd.hpp:25
config.hpp
result_type
result_traits< R, F >::type result_type
Definition: bind_template.hpp:15
boost
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
boost::multi_index::detail::ordered_index_equal_range
std::pair< Node *, Node * > ordered_index_equal_range(Node *top, Node *y, const KeyFromValue &key, const CompatibleKey &x, const CompatibleCompare &comp)
Definition: ord_index_ops.hpp:207
and.hpp
boost::multi_index::detail::ordered_index_find
Node * ordered_index_find(Node *top, Node *y, const KeyFromValue &key, const CompatibleKey &x, const CompatibleCompare &comp)
Definition: ord_index_ops.hpp:65
promotes_arg.hpp
boost::multi_index::detail::promotes_1st_arg
Definition: promotes_arg.hpp:34
boost::multi_index::detail::promotes_2nd_arg
Definition: promotes_arg.hpp:37
BOOST_DEDUCED_TYPENAME
#define BOOST_DEDUCED_TYPENAME
Definition: suffix.hpp:467
true_
bool_< true > true_
Definition: bool_fwd.hpp:21
boost::multi_index::detail::ordered_index_upper_bound
Node * ordered_index_upper_bound(Node *top, Node *y, const KeyFromValue &key, const CompatibleKey &x, const CompatibleCompare &comp)
Definition: ord_index_ops.hpp:161
boost::mpl::and_
Definition: mpl/aux_/preprocessed/bcc/and.hpp:48
boost::multi_index::detail::ordered_index_lower_bound
Node * ordered_index_lower_bound(Node *top, Node *y, const KeyFromValue &key, const CompatibleKey &x, const CompatibleCompare &comp)
Definition: ord_index_ops.hpp:115


sick_visionary_ros
Author(s): SICK AG TechSupport 3D Snapshot
autogenerated on Thu Feb 8 2024 03:45:36