]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/util/performance/assoc/multimap_common_type.hpp
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / util / performance / assoc / multimap_common_type.hpp
1 // -*- C++ -*-
2
3 // Copyright (C) 2005-2020 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the terms
7 // of the GNU General Public License as published by the Free Software
8 // Foundation; either version 3, or (at your option) any later
9 // version.
10
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
15
16 // You should have received a copy of the GNU General Public License
17 // along with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
19
20
21 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
22
23 // Permission to use, copy, modify, sell, and distribute this software
24 // is hereby granted without fee, provided that the above copyright
25 // notice appears in all copies, and that both that copyright notice
26 // and this permission notice appear in supporting documentation. None
27 // of the above authors, nor IBM Haifa Research Laboratories, make any
28 // representation about the suitability of this software for any
29 // purpose. It is provided "as is" without express or implied
30 // warranty.
31
32 /**
33 * @file multimap_common_type.hpp
34 * Contains types for a generic multimap_insert_test test.
35 */
36
37 #ifndef PB_DS_MULTIMAP_RANDOM_INT_INSERT_TEST_COMMON_TYPE_HPP
38 #define PB_DS_MULTIMAP_RANDOM_INT_INSERT_TEST_COMMON_TYPE_HPP
39
40 #include <hash_fn/string_hash_fn.hpp>
41 #include <common_type/assoc/common_type.hpp>
42
43 namespace __gnu_pbds
44 {
45 namespace test
46 {
47 namespace detail
48 {
49 struct int_hash : public std::unary_function<int, size_t>
50 {
51 inline size_t
52 operator()(const int i) const
53 { return (static_cast<size_t>(i)); }
54 };
55
56 template<typename Key, typename _Alloc = std::allocator<char> >
57 struct hash_set_tl_t
58 {
59 typedef
60 typename __gnu_pbds::test::hash_common_types<
61 Key,
62 __gnu_pbds::null_type,
63 int_hash,
64 std::equal_to<Key>,
65 _Alloc>::performance_min_tl
66 type;
67 };
68
69 template<typename Key, typename _Alloc = std::allocator<char> >
70 struct lu_set_tl_t
71 {
72 typedef
73 typename __gnu_pbds::test::lu_common_types<
74 Key,
75 __gnu_pbds::null_type,
76 std::equal_to<
77 Key>,
78 _Alloc>::performance_min_tl
79 type;
80 };
81
82 template<typename Key,
83 class Sec_Tl,
84 typename _Alloc = std::allocator<char> >
85 struct hash_mmap_tl_t
86 {
87 private:
88 typedef
89 typename __gnu_pbds::detail::__conditional_type<
90 __gnu_pbds::detail::is_same<
91 int,
92 Key>::value,
93 int_hash,
94 string_hash_fn>::__type
95 hash_fn_t;
96
97 template<typename Cntnr_T>
98 struct hash_mmap_transform
99 {
100 typedef
101 typename __gnu_pbds::test::hash_common_types<
102 Key,
103 Cntnr_T,
104 hash_fn_t,
105 std::equal_to<
106 Key>,
107 _Alloc>::performance_min_tl
108 type;
109 };
110
111 public:
112 typedef
113 typename __gnu_cxx::typelist::flatten<
114 typename __gnu_cxx::typelist::transform<
115 Sec_Tl,
116 hash_mmap_transform>::type>::type
117 type;
118 };
119
120 template<typename Key,
121 class Sec_Tl,
122 typename _Alloc = std::allocator<char> >
123 struct tree_mmap_tl_t
124 {
125 private:
126 template<typename Cntnr_T>
127 struct tree_mmap_transform
128 {
129 typedef
130 typename __gnu_pbds::test::tree_common_types<
131 Key,
132 Cntnr_T,
133 std::less<
134 Key>,
135 __gnu_pbds::null_node_update,
136 _Alloc>::performance_min_tl
137 type;
138 };
139
140 public:
141 typedef
142 typename __gnu_cxx::typelist::flatten<
143 typename __gnu_cxx::typelist::transform<
144 Sec_Tl,
145 tree_mmap_transform>::type>::type
146 type;
147 };
148
149 template<typename Key, typename Mapped, typename _Alloc>
150 struct hash_hash_mmap_tl_t
151 {
152 private:
153 typedef typename hash_set_tl_t<Mapped, _Alloc>::type sec_tl_t;
154
155 public:
156 typedef typename hash_mmap_tl_t<Key, sec_tl_t, _Alloc>::type type;
157 };
158
159 template<typename Key, typename Mapped, typename _Alloc>
160 struct tree_hash_mmap_tl_t
161 {
162 private:
163 typedef typename hash_set_tl_t<Mapped, _Alloc>::type sec_tl_t;
164
165 public:
166 typedef typename tree_mmap_tl_t<Key, sec_tl_t, _Alloc>::type type;
167 };
168
169 template<typename Key, typename Mapped, typename _Alloc>
170 struct tree_lu_mmap_tl_t
171 {
172 private:
173 typedef typename lu_set_tl_t<Mapped, _Alloc>::type sec_tl_t;
174
175 public:
176 typedef typename tree_mmap_tl_t<Key, sec_tl_t, _Alloc>::type type;
177 };
178
179 template<typename Key, typename Mapped, typename _Alloc>
180 struct hash_lu_mmap_tl_t
181 {
182 private:
183 typedef typename lu_set_tl_t<Mapped, _Alloc>::type sec_tl_t;
184
185 public:
186 typedef typename hash_mmap_tl_t<Key, sec_tl_t, _Alloc>::type type;
187 };
188 } // namespace detail
189
190 template<typename Key, typename Mapped, typename _Alloc>
191 struct mmap_tl_t
192 {
193 private:
194 typedef
195 typename detail::hash_hash_mmap_tl_t<Key, Mapped, _Alloc>::type
196 hh_mmap_tl_t;
197
198 typedef
199 typename detail::hash_lu_mmap_tl_t<Key, Mapped, _Alloc>::type
200 hl_mmap_tl_t;
201
202 typedef
203 typename detail::tree_hash_mmap_tl_t<Key, Mapped, _Alloc>::type
204 th_mmap_tl_t;
205
206 typedef
207 typename detail::tree_lu_mmap_tl_t<Key, Mapped, _Alloc>::type
208 tl_mmap_tl_t;
209
210 public:
211 typedef
212 typename __gnu_cxx::typelist::append<hl_mmap_tl_t,
213 typename __gnu_cxx::typelist::append<hh_mmap_tl_t,
214 typename __gnu_cxx::typelist::append<th_mmap_tl_t,
215 tl_mmap_tl_t>::type>::type>::type
216 type;
217 };
218
219 } // namespace test
220 } // namespace __gnu_pbds
221
222 #endif
223