]>
Commit | Line | Data |
---|---|---|
36fed23c | 1 | // -*- C++ -*- |
2 | ||
f1717362 | 3 | // Copyright (C) 2005-2016 Free Software Foundation, Inc. |
36fed23c | 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 | |
6bc9506f | 8 | // Foundation; either version 3, or (at your option) any later |
36fed23c | 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 | |
6bc9506f | 17 | // along with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
36fed23c | 19 | |
36fed23c | 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 template_policy.hpp | |
34 | * Contains template versions of policies. | |
35 | */ | |
36 | ||
37 | #ifndef PB_DS_TEMPLATE_POLICY_HPP | |
38 | #define PB_DS_TEMPLATE_POLICY_HPP | |
39 | ||
59ae0c9c | 40 | #include <ext/typelist.h> |
36fed23c | 41 | #include <ext/pb_ds/hash_policy.hpp> |
42 | #include <ext/pb_ds/tree_policy.hpp> | |
43 | #include <ext/pb_ds/list_update_policy.hpp> | |
44 | ||
b34535d7 | 45 | namespace __gnu_pbds |
36fed23c | 46 | { |
36fed23c | 47 | namespace test |
48 | { | |
4f4a327e | 49 | template<typename _Alloc> |
ce8b0a77 | 50 | struct direct_mask_range_hashing_t_ |
4f4a327e | 51 | : public __gnu_pbds::direct_mask_range_hashing<typename _Alloc::size_type> |
36fed23c | 52 | { |
4f4a327e | 53 | typedef typename _Alloc::size_type size_type; |
b34535d7 | 54 | typedef __gnu_pbds::direct_mask_range_hashing<size_type> base_type; |
36fed23c | 55 | }; |
56 | ||
4f4a327e | 57 | template<typename _Alloc> |
ce8b0a77 | 58 | struct direct_mod_range_hashing_t_ |
4f4a327e | 59 | : public __gnu_pbds::direct_mod_range_hashing<typename _Alloc::size_type> |
36fed23c | 60 | { |
4f4a327e | 61 | typedef typename _Alloc::size_type size_type; |
b34535d7 | 62 | typedef __gnu_pbds::direct_mod_range_hashing<size_type> base_type; |
36fed23c | 63 | }; |
64 | ||
4f4a327e | 65 | template<typename _Alloc, |
66 | typename _Alloc::size_type Min_Load_Nom, | |
67 | typename _Alloc::size_type Min_Load_Denom, | |
68 | typename _Alloc::size_type Max_Load_Nom, | |
69 | typename _Alloc::size_type Max_Load_Denom, | |
36fed23c | 70 | bool External_Access> |
ce8b0a77 | 71 | struct hash_load_check_resize_trigger_t_ |
b34535d7 | 72 | : public __gnu_pbds::hash_load_check_resize_trigger<External_Access, |
4f4a327e | 73 | typename _Alloc::size_type> |
36fed23c | 74 | { |
4f4a327e | 75 | typedef typename _Alloc::size_type size_type; |
b34535d7 | 76 | typedef __gnu_pbds::hash_load_check_resize_trigger<External_Access, size_type> base_type; |
36fed23c | 77 | |
78 | inline | |
ce8b0a77 | 79 | hash_load_check_resize_trigger_t_() |
80 | : base_type(static_cast<float>(Min_Load_Nom) / static_cast<float>(Min_Load_Denom), static_cast<float>(Max_Load_Nom) / static_cast<float>(Max_Load_Denom)) | |
36fed23c | 81 | { } |
82 | ||
83 | enum | |
84 | { | |
85 | get_set_loads = External_Access, | |
86 | get_set_load = false | |
87 | }; | |
88 | }; | |
89 | ||
4f4a327e | 90 | template<typename _Alloc, |
91 | typename _Alloc::size_type Load_Nom, | |
92 | typename _Alloc::size_type Load_Denom, | |
36fed23c | 93 | bool External_Access> |
ce8b0a77 | 94 | struct cc_hash_max_collision_check_resize_trigger_t_ |
b34535d7 | 95 | : public __gnu_pbds::cc_hash_max_collision_check_resize_trigger<External_Access, |
4f4a327e | 96 | typename _Alloc::size_type> |
36fed23c | 97 | { |
4f4a327e | 98 | typedef typename _Alloc::size_type size_type; |
b34535d7 | 99 | typedef __gnu_pbds::cc_hash_max_collision_check_resize_trigger<External_Access, size_type> base_type; |
36fed23c | 100 | |
101 | inline | |
ce8b0a77 | 102 | cc_hash_max_collision_check_resize_trigger_t_() |
103 | : base_type(static_cast<float>(Load_Nom) / static_cast<float>(Load_Denom)) | |
36fed23c | 104 | { } |
105 | ||
106 | enum | |
107 | { | |
108 | get_set_load = External_Access, | |
109 | get_set_loads = false | |
110 | }; | |
111 | }; | |
112 | ||
b34535d7 | 113 | struct hash_prime_size_policy_t_ : public __gnu_pbds::hash_prime_size_policy |
36fed23c | 114 | { }; |
115 | ||
4f4a327e | 116 | template<typename _Alloc> |
ce8b0a77 | 117 | struct hash_exponential_size_policy_t_ |
4f4a327e | 118 | : public __gnu_pbds::hash_exponential_size_policy<typename _Alloc::size_type> |
ce8b0a77 | 119 | { }; |
36fed23c | 120 | |
4f4a327e | 121 | template<typename Key, typename _Alloc> |
ce8b0a77 | 122 | struct linear_probe_fn_t_ |
4f4a327e | 123 | : public __gnu_pbds::linear_probe_fn<typename _Alloc::size_type> |
36fed23c | 124 | { }; |
125 | ||
4f4a327e | 126 | template<typename Key, typename _Alloc> |
ce8b0a77 | 127 | struct quadratic_probe_fn_t_ |
4f4a327e | 128 | : public __gnu_pbds::quadratic_probe_fn<typename _Alloc::size_type> |
36fed23c | 129 | { }; |
130 | ||
4f4a327e | 131 | template<typename _Alloc, typename _Alloc::size_type Max_Count> |
132 | struct lu_counter_policy_t_ | |
133 | : public __gnu_pbds::lu_counter_policy<Max_Count, _Alloc> | |
36fed23c | 134 | { |
4f4a327e | 135 | typedef __gnu_pbds::lu_counter_policy<Max_Count, _Alloc> base_type; |
36fed23c | 136 | }; |
137 | ||
4f4a327e | 138 | struct lu_move_to_front_policy_t_ |
139 | : public __gnu_pbds::lu_move_to_front_policy<> | |
36fed23c | 140 | { }; |
36fed23c | 141 | } // namespace test |
b34535d7 | 142 | } // namespace __gnu_pbds |
36fed23c | 143 | |
ce8b0a77 | 144 | #endif |
36fed23c | 145 |