Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
equal_iterator.hpp
1 // -*- C++ -*-
2 //
3 // Copyright Sylvain Bougerel 2009 - 2013.
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file COPYING or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 
13 #ifndef SPATIAL_EQUAL_ITERATOR_HPP
14 #define SPATIAL_EQUAL_ITERATOR_HPP
15 
16 #include "spatial.hpp"
17 #include "bits/spatial_equal.hpp"
18 
19 namespace spatial
20 {
27  template <typename Container>
29  : std::pair<equal_iterator<Container>,
30  equal_iterator<Container> >
31  {
36  typedef std::pair<equal_iterator<Container>,
38 
41 
46  : Base(a, b) { }
47  };
48 
55  template <typename Container>
56  struct equal_iterator_pair<const Container>
57  : std::pair<equal_iterator<const Container>,
58  equal_iterator<const Container> >
59  {
64  typedef std::pair<equal_iterator<const Container>,
66 
69 
74  : Base(a, b) { }
75 
79  : Base(p.first, p.second) { }
80  };
81 
90  template <typename Container>
92  inline equal_iterator_pair<Container>
93  equal_range(Container& container,
94  const typename equal_iterator<Container>::key_type& model)
95  {
97  (equal_begin(container, model), equal_end(container, model));
98  }
99 
100  template <typename Container>
101  inline equal_iterator_pair<const Container>
102  equal_range(const Container& container,
103  const typename equal_iterator<Container>::key_type& model)
104  {
106  (equal_begin(container, model), equal_end(container, model));
107  }
108 
109  template <typename Container>
110  inline equal_iterator_pair<const Container>
111  equal_crange(const Container& container,
112  const typename equal_iterator<Container>::key_type& model)
113  {
115  (equal_begin(container, model), equal_end(container, model));
116  }
118 
119 } // namespace spatial
120 
121 #endif // SPATIAL_EQUAL_ITERATOR_HPP
equal_iterator_pair()
Empty constructor.
This type provides an iterator to iterate through all elements of a container that match a given key...
This type provides an iterator to iterate through all elements of a container that match a given key...
equal_iterator_pair< Container > equal_range(Container &container, const typename equal_iterator< Container >::key_type &model)
Creates a pair of iterator that represent the range of element in the container that are equal to the...
equal_iterator_pair< const Container > equal_crange(const Container &container, const typename equal_iterator< Container >::key_type &model)
std::pair< equal_iterator< Container >, equal_iterator< Container > > Base
A pair of iterators that represents a range (that is: a range of elements to iterate, and not an orthogonal range).
This structure defines a pair of constant equal iterator.
std::pair< equal_iterator< const Container >, equal_iterator< const Container > > Base
A pair of iterators that represents a range (that is: a range of elements to iterate, and not an orthogonal range).
equal_iterator_pair(const equal_iterator< Container > &a, const equal_iterator< Container > &b)
Regular constructor that builds a equal_iterator_pair out of 2 equal_iterators.
The main namespace used in the library.
Definition: algorithm.hpp:23
equal_iterator< Container > equal_end(Container &container, const typename equal_iterator< Container >::key_type &value)
equal_iterator_pair(const equal_iterator_pair< Container > &p)
Convert a mutable equal iterator pair into a const equal iterator pair.
This structure defines a pair of mutable equal iterator.
container_traits< Container >::key_type key_type
The type used to store the model key to be looked up in the container.
equal_iterator< Container > equal_begin(Container &container, const typename equal_iterator< Container >::key_type &value)
Find the first element in container that compares equally to value, using container's key_compare com...
equal_iterator_pair(const equal_iterator< const Container > &a, const equal_iterator< const Container > &b)
Regular constructor that builds a equal_iterator_pair out of 2 equal_iterators.