1 // TR1 unordered_map -*- C++ -*-
3 // Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
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
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 /** @file tr1/unordered_map
31 * This is a TR1 C++ Library header.
34 #ifndef _TR1_UNORDERED_MAP
35 #define _TR1_UNORDERED_MAP 1
37 #include <tr1/hashtable>
38 #include <tr1/functional_hash.h>
42 _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
44 // XXX When we get typedef templates these class definitions
45 // will be unnecessary.
46 template<class _Key, class _Tp,
47 class _Hash = hash<_Key>,
48 class _Pred = std::equal_to<_Key>,
49 class _Alloc = std::allocator<std::pair<const _Key, _Tp> >,
50 bool __cache_hash_code = false>
52 : public _Hashtable<_Key, std::pair<const _Key, _Tp>, _Alloc,
53 std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
54 _Hash, __detail::_Mod_range_hashing,
55 __detail::_Default_ranged_hash,
56 __detail::_Prime_rehash_policy,
57 __cache_hash_code, false, true>
59 typedef _Hashtable<_Key, std::pair<const _Key, _Tp>, _Alloc,
60 std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
61 _Hash, __detail::_Mod_range_hashing,
62 __detail::_Default_ranged_hash,
63 __detail::_Prime_rehash_policy,
64 __cache_hash_code, false, true>
68 typedef typename _Base::size_type size_type;
69 typedef typename _Base::hasher hasher;
70 typedef typename _Base::key_equal key_equal;
71 typedef typename _Base::allocator_type allocator_type;
74 __unordered_map(size_type __n = 10,
75 const hasher& __hf = hasher(),
76 const key_equal& __eql = key_equal(),
77 const allocator_type& __a = allocator_type())
78 : _Base(__n, __hf, __detail::_Mod_range_hashing(),
79 __detail::_Default_ranged_hash(),
80 __eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
83 template<typename _InputIterator>
84 __unordered_map(_InputIterator __f, _InputIterator __l,
86 const hasher& __hf = hasher(),
87 const key_equal& __eql = key_equal(),
88 const allocator_type& __a = allocator_type())
89 : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
90 __detail::_Default_ranged_hash(),
91 __eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
95 template<class _Key, class _Tp,
96 class _Hash = hash<_Key>,
97 class _Pred = std::equal_to<_Key>,
98 class _Alloc = std::allocator<std::pair<const _Key, _Tp> >,
99 bool __cache_hash_code = false>
100 class __unordered_multimap
101 : public _Hashtable<_Key, std::pair<const _Key, _Tp>,
103 std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
104 _Hash, __detail::_Mod_range_hashing,
105 __detail::_Default_ranged_hash,
106 __detail::_Prime_rehash_policy,
107 __cache_hash_code, false, false>
109 typedef _Hashtable<_Key, std::pair<const _Key, _Tp>,
111 std::_Select1st<std::pair<const _Key, _Tp> >, _Pred,
112 _Hash, __detail::_Mod_range_hashing,
113 __detail::_Default_ranged_hash,
114 __detail::_Prime_rehash_policy,
115 __cache_hash_code, false, false>
119 typedef typename _Base::size_type size_type;
120 typedef typename _Base::hasher hasher;
121 typedef typename _Base::key_equal key_equal;
122 typedef typename _Base::allocator_type allocator_type;
125 __unordered_multimap(size_type __n = 10,
126 const hasher& __hf = hasher(),
127 const key_equal& __eql = key_equal(),
128 const allocator_type& __a = allocator_type())
129 : _Base(__n, __hf, __detail::_Mod_range_hashing(),
130 __detail::_Default_ranged_hash(),
131 __eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
135 template<typename _InputIterator>
136 __unordered_multimap(_InputIterator __f, _InputIterator __l,
137 typename _Base::size_type __n = 0,
138 const hasher& __hf = hasher(),
139 const key_equal& __eql = key_equal(),
140 const allocator_type& __a = allocator_type())
141 : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
142 __detail::_Default_ranged_hash(),
143 __eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
147 template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
148 bool __cache_hash_code>
150 swap(__unordered_map<_Key, _Tp, _Hash, _Pred,
151 _Alloc, __cache_hash_code>& __x,
152 __unordered_map<_Key, _Tp, _Hash, _Pred,
153 _Alloc, __cache_hash_code>& __y)
156 template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc,
157 bool __cache_hash_code>
159 swap(__unordered_multimap<_Key, _Tp, _Hash, _Pred,
160 _Alloc, __cache_hash_code>& __x,
161 __unordered_multimap<_Key, _Tp, _Hash, _Pred,
162 _Alloc, __cache_hash_code>& __y)
166 template<class _Key, class _Tp,
167 class _Hash = hash<_Key>,
168 class _Pred = std::equal_to<_Key>,
169 class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
171 : public __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>
173 typedef __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> _Base;
176 typedef typename _Base::size_type size_type;
177 typedef typename _Base::hasher hasher;
178 typedef typename _Base::key_equal key_equal;
179 typedef typename _Base::allocator_type allocator_type;
182 unordered_map(size_type __n = 10,
183 const hasher& __hf = hasher(),
184 const key_equal& __eql = key_equal(),
185 const allocator_type& __a = allocator_type())
186 : _Base(__n, __hf, __eql, __a)
189 template<typename _InputIterator>
190 unordered_map(_InputIterator __f, _InputIterator __l,
192 const hasher& __hf = hasher(),
193 const key_equal& __eql = key_equal(),
194 const allocator_type& __a = allocator_type())
195 : _Base(__f, __l, __n, __hf, __eql, __a)
199 template<class _Key, class _Tp,
200 class _Hash = hash<_Key>,
201 class _Pred = std::equal_to<_Key>,
202 class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
203 class unordered_multimap
204 : public __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>
206 typedef __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> _Base;
209 typedef typename _Base::size_type size_type;
210 typedef typename _Base::hasher hasher;
211 typedef typename _Base::key_equal key_equal;
212 typedef typename _Base::allocator_type allocator_type;
215 unordered_multimap(size_type __n = 10,
216 const hasher& __hf = hasher(),
217 const key_equal& __eql = key_equal(),
218 const allocator_type& __a = allocator_type())
219 : _Base(__n, __hf, __eql, __a)
223 template<typename _InputIterator>
224 unordered_multimap(_InputIterator __f, _InputIterator __l,
225 typename _Base::size_type __n = 0,
226 const hasher& __hf = hasher(),
227 const key_equal& __eql = key_equal(),
228 const allocator_type& __a = allocator_type())
229 : _Base(__f, __l, __n, __hf, __eql, __a)
233 _GLIBCXX_END_NAMESPACE
236 #endif // _TR1_UNORDERED_MAP