]>
Commit | Line | Data |
---|---|---|
4569a895 AT |
1 | // -*- C++ -*- |
2 | ||
99dee823 | 3 | // Copyright (C) 2005-2021 Free Software Foundation, Inc. |
4569a895 AT |
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 | |
748086b7 | 8 | // Foundation; either version 3, or (at your option) any later |
4569a895 AT |
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 | |
748086b7 JJ |
17 | // along with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
4569a895 | 19 | |
4569a895 AT |
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 common_type.hpp | |
34 | * Contains types used for regression tests. | |
35 | */ | |
36 | ||
37 | #ifndef PB_DS_RAND_REGRESSION_TEST_COMMON_TYPE_HPP | |
38 | #define PB_DS_RAND_REGRESSION_TEST_COMMON_TYPE_HPP | |
39 | ||
2e3f9c21 | 40 | #include <vector> |
4569a895 AT |
41 | #include <regression/basic_type.hpp> |
42 | #include <common_type/assoc/common_type.hpp> | |
2e3f9c21 | 43 | #include <common_type/priority_queue/common_type.hpp> |
4569a895 | 44 | |
5e11f978 | 45 | namespace __gnu_pbds |
4569a895 | 46 | { |
55a4c999 BK |
47 | namespace test |
48 | { | |
861de21e | 49 | typedef __gnu_cxx::throw_allocator_random<basic_type> alloc_type; |
4569a895 | 50 | |
55a4c999 | 51 | struct hash |
4569a895 | 52 | { |
3441f106 BK |
53 | typedef alloc_type::rebind<basic_type>::other basic_type_rebind; |
54 | typedef basic_type_rebind::const_reference const_reference; | |
55 | typedef basic_type::const_iterator const_iterator; | |
4569a895 | 56 | |
55a4c999 | 57 | size_t |
3441f106 | 58 | operator()(const_reference r_key) const |
4569a895 | 59 | { |
55a4c999 | 60 | size_t ret = 0; |
55a4c999 BK |
61 | for (const_iterator it = r_key.begin(); it != r_key.end(); ++it) |
62 | ret = ret * 5 + static_cast<size_t>(*it); | |
63 | return ret; | |
64 | } | |
65 | }; | |
66 | ||
a345e45d | 67 | typedef __gnu_pbds::trie_string_access_traits<basic_type, 'a', 'a' + basic_type::distinct_chars - 1, false, alloc_type> access_traits_t; |
55a4c999 BK |
68 | |
69 | template<typename Data_Type> | |
70 | struct tree_types | |
71 | { | |
72 | private: | |
a345e45d | 73 | typedef typename tree_common_types<basic_type, Data_Type, std::less<basic_type>, __gnu_pbds::null_node_update, alloc_type>::regression_tl no_order_statistics_tl_t; |
4569a895 | 74 | |
5e11f978 | 75 | typedef typename tree_common_types<basic_type, Data_Type, std::less<basic_type>, __gnu_pbds::tree_order_statistics_node_update, alloc_type>::regression_tl order_statistics_tl_t; |
4569a895 | 76 | |
55a4c999 | 77 | public: |
d7f245b1 | 78 | typedef typename __gnu_cxx::typelist::append<no_order_statistics_tl_t, order_statistics_tl_t>::type tl_t; |
4569a895 | 79 | |
55a4c999 BK |
80 | typedef no_order_statistics_tl_t min_tl_t; |
81 | }; | |
4569a895 | 82 | |
55a4c999 BK |
83 | template<typename Data_Type> |
84 | struct trie_types | |
85 | { | |
86 | private: | |
a345e45d | 87 | typedef typename trie_common_types<basic_type, Data_Type, access_traits_t, __gnu_pbds::pat_trie_tag, __gnu_pbds::null_node_update, alloc_type>::regression_tl no_updates_tl_t; |
4569a895 | 88 | |
a345e45d | 89 | typedef typename trie_common_types<basic_type, Data_Type, access_traits_t, __gnu_pbds::pat_trie_tag, __gnu_pbds::trie_order_statistics_node_update, alloc_type>::regression_tl order_statistics_tl_t; |
4569a895 | 90 | |
a345e45d | 91 | typedef typename trie_common_types<basic_type, Data_Type, access_traits_t, __gnu_pbds::pat_trie_tag, __gnu_pbds::trie_prefix_search_node_update, alloc_type>::regression_tl prefix_search_tl_t; |
4569a895 | 92 | |
55a4c999 | 93 | public: |
d7f245b1 | 94 | typedef typename __gnu_cxx::typelist::append<no_updates_tl_t, typename __gnu_cxx::typelist::append<prefix_search_tl_t, order_statistics_tl_t>::type>::type tl_t; |
4569a895 | 95 | |
55a4c999 BK |
96 | typedef no_updates_tl_t min_tl_t; |
97 | }; | |
4569a895 | 98 | |
55a4c999 BK |
99 | template<typename Data_Type> |
100 | struct hash_types | |
101 | { | |
102 | typedef typename hash_common_types<basic_type, Data_Type, hash, std::equal_to<basic_type>, alloc_type>::regression_tl tl_t; | |
4569a895 | 103 | |
55a4c999 BK |
104 | typedef tl_t min_tl_t; |
105 | }; | |
4569a895 | 106 | |
55a4c999 BK |
107 | template<typename Data_Type> |
108 | struct lu_types | |
109 | { | |
110 | typedef typename lu_common_types<basic_type, Data_Type, std::equal_to<basic_type>, alloc_type>::regression_tl tl_t; | |
111 | ||
112 | typedef tl_t min_tl_t; | |
113 | }; | |
f92ab29f | 114 | |
2e3f9c21 BK |
115 | // Sequence types. |
116 | typedef pq_common_types<basic_type, std::less<basic_type>, alloc_type> pq_types; | |
f92ab29f | 117 | |
2e3f9c21 BK |
118 | typedef pq_types::regression_tl pq_tl_t; |
119 | typedef pq_tl_t min_pq_tl_t; | |
120 | ||
121 | template<typename _Tp, typename _Alloc> | |
122 | struct vector_adaptor : public std::vector<_Tp, _Alloc> | |
123 | { | |
124 | private: | |
125 | typedef std::vector<_Tp, _Alloc> base_type; | |
126 | ||
127 | public: | |
128 | typedef typename base_type::value_type value_type; | |
f92ab29f CG |
129 | typedef typename base_type::pointer pointer; |
130 | typedef typename base_type::const_pointer const_pointer; | |
131 | typedef typename base_type::reference reference; | |
132 | typedef typename base_type::const_reference const_reference; | |
133 | typedef typename base_type::iterator iterator; | |
134 | typedef typename base_type::const_iterator const_iterator; | |
135 | typedef typename base_type::reverse_iterator reverse_iterator; | |
136 | typedef typename base_type::const_reverse_iterator const_reverse_iterator; | |
2e3f9c21 BK |
137 | typedef typename base_type::size_type size_type; |
138 | typedef typename base_type::difference_type difference_type; | |
139 | typedef typename base_type::allocator_type allocator_type; | |
140 | ||
141 | typedef __gnu_pbds::sequence_tag container_category; | |
142 | typedef std::less<_Tp> cmp_fn; | |
143 | ||
f92ab29f | 144 | const cmp_fn& |
2e3f9c21 BK |
145 | get_cmp_fn() const |
146 | { return _M_cmp; } | |
147 | ||
148 | vector_adaptor() { } | |
149 | vector_adaptor(iterator) { } | |
150 | vector_adaptor(iterator, iterator) { } | |
151 | vector_adaptor(iterator, iterator, const cmp_fn&) { } | |
152 | vector_adaptor(const cmp_fn& other) { } | |
153 | ||
154 | using base_type::push_back; | |
155 | using base_type::pop_back; | |
156 | ||
157 | // erase_if | |
158 | ||
159 | cmp_fn _M_cmp; | |
160 | ||
161 | }; | |
f92ab29f | 162 | |
2e3f9c21 BK |
163 | typedef vector_adaptor<basic_type, alloc_type> vector_type; |
164 | typedef __gnu_cxx::typelist::create1<vector_type>::type vector_tl_t; | |
55a4c999 | 165 | |
2e3f9c21 | 166 | // Associative types. |
a345e45d BK |
167 | typedef tree_types<null_type>::tl_t tree_set_tl_t; |
168 | typedef tree_types<null_type>::min_tl_t min_tree_set_tl_t; | |
55a4c999 BK |
169 | typedef tree_types<basic_type>::tl_t tree_map_tl_t; |
170 | typedef tree_types<basic_type>::min_tl_t min_tree_map_tl_t; | |
171 | ||
a345e45d BK |
172 | typedef hash_types<null_type>::tl_t hash_set_tl_t; |
173 | typedef hash_types<null_type>::min_tl_t min_hash_set_tl_t; | |
55a4c999 BK |
174 | typedef hash_types<basic_type>::tl_t hash_map_tl_t; |
175 | typedef hash_types<basic_type>::min_tl_t min_hash_map_tl_t; | |
176 | ||
a345e45d BK |
177 | typedef lu_types<null_type>::tl_t lu_set_tl_t; |
178 | typedef lu_types<null_type>::min_tl_t min_lu_set_tl_t; | |
55a4c999 BK |
179 | typedef lu_types<basic_type>::tl_t lu_map_tl_t; |
180 | typedef lu_types<basic_type>::min_tl_t min_lu_map_tl_t; | |
181 | ||
a345e45d BK |
182 | typedef trie_types<null_type>::tl_t trie_set_tl_t; |
183 | typedef trie_types<null_type>::min_tl_t min_trie_set_tl_t; | |
55a4c999 BK |
184 | typedef trie_types<basic_type>::tl_t trie_map_tl_t; |
185 | typedef trie_types<basic_type>::min_tl_t min_trie_map_tl_t; | |
186 | } // namespace test | |
5e11f978 | 187 | } // namespace __gnu_pbds |
4569a895 | 188 | |
f92ab29f | 189 | #endif |