Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
idle_point_multiset.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 
23 #ifndef SPATIAL_IDLE_POINT_MULTISET_HPP
24 #define SPATIAL_IDLE_POINT_MULTISET_HPP
25 
26 #include <memory> // std::allocator
27 #include "function.hpp"
28 #include "bits/spatial_kdtree.hpp"
29 
30 namespace spatial
31 {
32 
33  template<dimension_type Rank, typename Key,
34  typename Compare = bracket_less<Key>,
35  typename Alloc = std::allocator<Key> >
37  : details::Kdtree<details::Static_rank<Rank>,
38  const Key, const Key, Compare, Alloc>
39  {
40  private:
41  typedef details::Kdtree<details::Static_rank<Rank>, const Key, const Key,
42  Compare, Alloc> base_type;
44 
45  public:
47 
48  explicit idle_point_multiset(const Compare& compare)
49  : base_type(details::Static_rank<Rank>(), compare)
50  { }
51 
52  idle_point_multiset(const Compare& compare, const Alloc& alloc)
53  : base_type(details::Static_rank<Rank>(), compare, alloc)
54  { }
55 
56  idle_point_multiset(const idle_point_multiset& other, bool balancing = false)
57  : base_type(other, balancing)
58  { }
59 
62  {
63  return static_cast<Self&>(base_type::operator=(other));
64  }
65  };
66 
79  template<typename Key, typename Compare, typename Alloc>
80  struct idle_point_multiset<0, Key, Compare, Alloc>
81  : details::Kdtree<details::Dynamic_rank, const Key, const Key,
82  Compare, Alloc>
83  {
84  private:
85  typedef details::Kdtree<details::Dynamic_rank, const Key, const Key,
86  Compare, Alloc> base_type;
88 
89  public:
91 
93  : base_type(details::Dynamic_rank(dim))
94  { except::check_rank(dim); }
95 
96  idle_point_multiset(dimension_type dim, const Compare& compare)
97  : base_type(details::Dynamic_rank(dim), compare)
98  { except::check_rank(dim); }
99 
100  explicit idle_point_multiset(const Compare& compare)
101  : base_type(compare)
102  { }
103 
104  idle_point_multiset(dimension_type dim, const Compare& compare,
105  const Alloc& alloc)
106  : base_type(details::Dynamic_rank(dim), compare, alloc)
107  { except::check_rank(dim); }
108 
109  idle_point_multiset(const Compare& compare, const Alloc& alloc)
110  : base_type(details::Dynamic_rank(), compare, alloc)
111  { }
112 
113  idle_point_multiset(const idle_point_multiset& other, bool balancing = false)
114  : base_type(other, balancing)
115  { }
116 
119  {
120  return static_cast<Self&>(base_type::operator=(other));
121  }
122  };
123 
124 }
125 
126 #endif // SPATIAL_IDLE_POINT_MULTISET_HPP
The dimension value is stored by a member of the object, but can be modified at run time...
idle_point_multiset(const Compare &compare, const Alloc &alloc)
details::Kdtree< details::Dynamic_rank, const Key, const Key, Compare, Alloc > base_type
Specialization for spatial::idle_point_multiset with runtime rank support.
idle_point_multiset(dimension_type dim, const Compare &compare)
idle_point_multiset(dimension_type dim, const Compare &compare, const Alloc &alloc)
void check_rank(dimension_type rank)
Checks that rank is not null.
idle_point_multiset< Rank, Key, Compare, Alloc > Self
idle_point_multiset< 0, Key, Compare, Alloc > Self
std::size_t dimension_type
Defines the type for the dimension as being a size.
Definition: spatial.hpp:71
idle_point_multiset & operator=(const idle_point_multiset &other)
The main namespace used in the library.
Definition: algorithm.hpp:23
Detailed implementation of the kd-tree.
idle_point_multiset & operator=(const idle_point_multiset &other)
idle_point_multiset(const idle_point_multiset &other, bool balancing=false)
idle_point_multiset(const Compare &compare, const Alloc &alloc)
idle_point_multiset(const idle_point_multiset &other, bool balancing=false)
Self & operator=(const Self &other)
Assignment of other into the tree, with deep copy.
idle_point_multiset(const Compare &compare)
details::Kdtree< details::Static_rank< Rank >, const Key, const Key, Compare, Alloc > base_type