fix doc example typo
[boost.git] / boost / bimap / views / vector_map_view.hpp
blob1837c2797ca670fd89a7d0f361669ac5445db190
1 // Boost.Bimap
2 //
3 // Copyright (c) 2006-2007 Matias Capeletto
4 //
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 /// \file views/vector_map_view.hpp
10 /// \brief View of a side of a bimap.
12 #ifndef BOOST_BIMAP_VIEWS_VECTOR_MAP_VIEW_HPP
13 #define BOOST_BIMAP_VIEWS_VECTOR_MAP_VIEW_HPP
15 #if defined(_MSC_VER) && (_MSC_VER>=1200)
16 #pragma once
17 #endif
19 #include <boost/config.hpp>
21 #include <boost/bimap/container_adaptor/vector_map_adaptor.hpp>
22 #include <boost/bimap/support/iterator_type_by.hpp>
23 #include <boost/bimap/detail/map_view_base.hpp>
24 #include <boost/bimap/container_adaptor/detail/comparison_adaptor.hpp>
26 namespace boost {
27 namespace bimaps {
28 namespace views {
30 /// \brief View of a side of a bimap.
31 /**
33 This class uses container_adaptor and iterator_adaptor to wrapped a index of the
34 multi_index bimap core.
36 See also const_map_view.
37 **/
38 template< class Tag, class BimapType >
39 class vector_map_view
41 public BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
42 vector_map_adaptor,
43 Tag,BimapType,
44 reverse_iterator_type_by, const_reverse_iterator_type_by
47 public ::boost::bimaps::detail::
48 map_view_base< vector_map_view<Tag,BimapType>,Tag,BimapType >
50 typedef BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
51 vector_map_adaptor,
52 Tag,BimapType,
53 reverse_iterator_type_by, const_reverse_iterator_type_by
55 ) base_;
57 BOOST_BIMAP_MAP_VIEW_BASE_FRIEND(vector_map_view,Tag,BimapType)
59 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::data_extractor
61 Tag,
62 BOOST_DEDUCED_TYPENAME BimapType::relation
64 >::type key_from_base_value;
66 public:
68 typedef BOOST_DEDUCED_TYPENAME base_::value_type::info_type info_type;
70 vector_map_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) :
71 base_(c) {}
73 vector_map_view & operator=(const vector_map_view & v)
75 this->base() = v.base();
76 return *this;
79 BOOST_BIMAP_VIEW_ASSIGN_IMPLEMENTATION(base_)
81 BOOST_BIMAP_VIEW_FRONT_BACK_IMPLEMENTATION(base_)
83 // Lists operations
85 void splice(BOOST_DEDUCED_TYPENAME base_::iterator position, vector_map_view & x)
87 this->base().splice(
88 this->template functor<
89 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
90 x.base()
94 void splice(BOOST_DEDUCED_TYPENAME base_::iterator position,
95 vector_map_view & x,
96 BOOST_DEDUCED_TYPENAME base_::iterator i)
98 this->base().splice(
99 this->template functor<
100 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
101 x.base(),
102 this->template functor<
103 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(i)
107 void splice(BOOST_DEDUCED_TYPENAME base_::iterator position,
108 vector_map_view & x,
109 BOOST_DEDUCED_TYPENAME base_::iterator first,
110 BOOST_DEDUCED_TYPENAME base_::iterator last)
112 this->base().splice(
113 this->template functor<
114 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
115 x.base(),
116 this->template functor<
117 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(first),
118 this->template functor<
119 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(last)
123 void remove(BOOST_DEDUCED_TYPENAME ::boost::call_traits<
124 BOOST_DEDUCED_TYPENAME base_::value_type >::param_type value)
126 this->base().remove(
127 this->template functor<
128 BOOST_DEDUCED_TYPENAME base_::value_to_base>()(value)
132 template< class Predicate >
133 void remove_if(Predicate pred)
135 this->base().remove_if(
136 ::boost::bimaps::container_adaptor::detail::unary_check_adaptor
138 Predicate,
139 BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
140 key_from_base_value
142 >( pred, key_from_base_value() )
146 void unique()
148 this->base().unique(
149 ::boost::bimaps::container_adaptor::detail::comparison_adaptor
151 std::equal_to<BOOST_DEDUCED_TYPENAME base_::key_type>,
152 BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
153 key_from_base_value
155 >(std::equal_to<BOOST_DEDUCED_TYPENAME base_::key_type>(),
156 key_from_base_value() )
160 template< class BinaryPredicate >
161 void unique(BinaryPredicate binary_pred)
163 this->base().unique(
164 ::boost::bimaps::container_adaptor::detail::comparison_adaptor
166 BinaryPredicate,
167 BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
168 key_from_base_value
170 >( binary_pred, key_from_base_value() )
174 void merge(vector_map_view & x)
176 this->base().merge(x.base(),
177 ::boost::bimaps::container_adaptor::detail::comparison_adaptor
179 std::less<BOOST_DEDUCED_TYPENAME base_::key_type>,
180 BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
181 key_from_base_value
183 >( std::less<BOOST_DEDUCED_TYPENAME base_::key_type>(),
184 key_from_base_value() )
188 template< class Compare >
189 void merge(vector_map_view & x, Compare comp)
191 this->base().merge(x.base(),
192 ::boost::bimaps::container_adaptor::detail::comparison_adaptor
194 Compare,
195 BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
196 key_from_base_value
198 >( comp, key_from_base_value() )
202 void sort()
204 this->base().sort(
205 ::boost::bimaps::container_adaptor::detail::comparison_adaptor
207 std::less<BOOST_DEDUCED_TYPENAME base_::key_type>,
208 BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
209 key_from_base_value
211 >( std::less<BOOST_DEDUCED_TYPENAME base_::key_type>(),
212 key_from_base_value() )
216 template< class Compare >
217 void sort(Compare comp)
219 this->base().sort(
220 ::boost::bimaps::container_adaptor::detail::comparison_adaptor
222 Compare,
223 BOOST_DEDUCED_TYPENAME base_::base_type::value_type,
224 key_from_base_value
226 >( comp, key_from_base_value() )
230 void reverse()
232 this->base().reverse();
235 // Rearrange Operations
237 void relocate(BOOST_DEDUCED_TYPENAME base_::iterator position,
238 BOOST_DEDUCED_TYPENAME base_::iterator i)
240 this->base().relocate(
241 this->template functor<
242 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
243 this->template functor<
244 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(i)
248 void relocate(BOOST_DEDUCED_TYPENAME base_::iterator position,
249 BOOST_DEDUCED_TYPENAME base_::iterator first,
250 BOOST_DEDUCED_TYPENAME base_::iterator last)
252 this->base().relocate(
253 this->template functor<
254 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
255 this->template functor<
256 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(first),
257 this->template functor<
258 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(last)
265 } // namespace views
267 /*===========================================================================*/
268 #define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,TYPENAME) \
269 typedef BOOST_DEDUCED_TYPENAME MAP_VIEW::TYPENAME \
270 BOOST_PP_CAT(SIDE,BOOST_PP_CAT(_,TYPENAME));
271 /*===========================================================================*/
273 /*===========================================================================*/
274 #define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(MAP_VIEW,SIDE) \
275 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,reverse_iterator) \
276 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_reverse_iterator) \
277 /*===========================================================================*/
279 namespace detail {
281 template< class Tag, class BimapType >
282 struct left_map_view_extra_typedefs< ::boost::bimaps::views::vector_map_view<Tag,BimapType> >
284 private: typedef ::boost::bimaps::views::vector_map_view<Tag,BimapType> map_view_;
285 public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,left)
288 template< class Tag, class BimapType >
289 struct right_map_view_extra_typedefs< ::boost::bimaps::views::vector_map_view<Tag,BimapType> >
291 private: typedef ::boost::bimaps::views::vector_map_view<Tag,BimapType> map_view_;
292 public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,right)
295 } // namespace detail
297 /*===========================================================================*/
298 #undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF
299 #undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY
300 /*===========================================================================*/
302 } // namespace bimaps
303 } // namespace boost
305 #endif // BOOST_BIMAP_VIEWS_VECTOR_MAP_VIEW_HPP