Rework the trip history window layout.
[openttd-joker.git] / src / 3rdparty / cpp-btree / btree_set.h
blobabc69d73395214503642fdd1bbee1a0860dc49bc
1 // Copyright 2013 Google Inc. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 // A btree_set<> implements the STL unique sorted associative container
16 // interface (a.k.a set<>) using a btree. A btree_multiset<> implements the STL
17 // multiple sorted associative container interface (a.k.a multiset<>) using a
18 // btree. See btree.h for details of the btree implementation and caveats.
20 #ifndef UTIL_BTREE_BTREE_SET_H__
21 #define UTIL_BTREE_BTREE_SET_H__
23 #include <functional>
24 #include <memory>
25 #include <string>
27 #include "btree.h"
28 #include "btree_container.h"
30 namespace btree {
32 // The btree_set class is needed mainly for its constructors.
33 template <typename Key,
34 typename Compare = std::less<Key>,
35 typename Alloc = std::allocator<Key>,
36 int TargetNodeSize = 256>
37 class btree_set : public btree_unique_container<
38 btree<btree_set_params<Key, Compare, Alloc, TargetNodeSize> > > {
40 typedef btree_set<Key, Compare, Alloc, TargetNodeSize> self_type;
41 typedef btree_set_params<Key, Compare, Alloc, TargetNodeSize> params_type;
42 typedef btree<params_type> btree_type;
43 typedef btree_unique_container<btree_type> super_type;
45 public:
46 typedef typename btree_type::key_compare key_compare;
47 typedef typename btree_type::allocator_type allocator_type;
49 public:
50 // Default constructor.
51 btree_set(const key_compare &comp = key_compare(),
52 const allocator_type &alloc = allocator_type())
53 : super_type(comp, alloc) {
56 // Copy constructor.
57 btree_set(const self_type &x)
58 : super_type(x) {
61 // Move constructor.
62 btree_set(self_type &&x)
63 : super_type() {
64 this->swap(x);
67 // Copy/move assignment
68 self_type& operator=(self_type x) {
69 this->swap(x);
70 return *this;
73 // Range constructor.
74 template <class InputIterator>
75 btree_set(InputIterator b, InputIterator e,
76 const key_compare &comp = key_compare(),
77 const allocator_type &alloc = allocator_type())
78 : super_type(b, e, comp, alloc) {
82 template <typename K, typename C, typename A, int N>
83 inline void swap(btree_set<K, C, A, N> &x, btree_set<K, C, A, N> &y) {
84 x.swap(y);
87 // The btree_multiset class is needed mainly for its constructors.
88 template <typename Key,
89 typename Compare = std::less<Key>,
90 typename Alloc = std::allocator<Key>,
91 int TargetNodeSize = 256>
92 class btree_multiset : public btree_multi_container<
93 btree<btree_set_params<Key, Compare, Alloc, TargetNodeSize> > > {
95 typedef btree_multiset<Key, Compare, Alloc, TargetNodeSize> self_type;
96 typedef btree_set_params<Key, Compare, Alloc, TargetNodeSize> params_type;
97 typedef btree<params_type> btree_type;
98 typedef btree_multi_container<btree_type> super_type;
100 public:
101 typedef typename btree_type::key_compare key_compare;
102 typedef typename btree_type::allocator_type allocator_type;
104 public:
105 // Default constructor.
106 btree_multiset(const key_compare &comp = key_compare(),
107 const allocator_type &alloc = allocator_type())
108 : super_type(comp, alloc) {
111 // Copy constructor.
112 btree_multiset(const self_type &x)
113 : super_type(x) {
116 // Move constructor.
117 btree_multiset(self_type &&x)
118 : super_type() {
119 this->swap(x);
122 // Copy/move assignment
123 self_type& operator=(self_type x) {
124 this->swap(x);
125 return *this;
128 // Range constructor.
129 template <class InputIterator>
130 btree_multiset(InputIterator b, InputIterator e,
131 const key_compare &comp = key_compare(),
132 const allocator_type &alloc = allocator_type())
133 : super_type(b, e, comp, alloc) {
137 template <typename K, typename C, typename A, int N>
138 inline void swap(btree_multiset<K, C, A, N> &x,
139 btree_multiset<K, C, A, N> &y) {
140 x.swap(y);
143 } // namespace btree
145 #endif // UTIL_BTREE_BTREE_SET_H__