1 // TR1 unordered_map -*- C++ -*-
3 // Copyright (C) 2005, 2006 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.
31 * This is a TR1 C++ Library header.
34 #ifndef GNU_LIBSTDCXX_TR1_UNORDERED_MAP_
35 #define GNU_LIBSTDCXX_TR1_UNORDERED_MAP_
37 #include <tr1/hashtable>
38 #include <tr1/functional>
42 _GLIBCXX_BEGIN_NAMESPACE(tr1)
44 // XXX When we get typedef templates these class definitions
45 // will be unnecessary.
47 template<class Key, class T,
48 class Hash = hash<Key>,
49 class Pred = std::equal_to<Key>,
50 class Alloc = std::allocator<std::pair<const Key, T> >,
51 bool cache_hash_code = false>
53 : public hashtable <Key, std::pair<const Key, T>,
55 Internal::extract1st<std::pair<const Key, T> >, Pred,
56 Hash, Internal::mod_range_hashing,
57 Internal::default_ranged_hash,
58 Internal::prime_rehash_policy,
59 cache_hash_code, false, true>
61 typedef hashtable <Key, std::pair<const Key, T>,
63 Internal::extract1st<std::pair<const Key, T> >, Pred,
64 Hash, Internal::mod_range_hashing,
65 Internal::default_ranged_hash,
66 Internal::prime_rehash_policy,
67 cache_hash_code, false, true>
71 typedef typename Base::size_type size_type;
72 typedef typename Base::hasher hasher;
73 typedef typename Base::key_equal key_equal;
74 typedef typename Base::allocator_type allocator_type;
77 unordered_map(size_type n = 10,
78 const hasher& hf = hasher(),
79 const key_equal& eql = key_equal(),
80 const allocator_type& a = allocator_type())
81 : Base(n, hf, Internal::mod_range_hashing(),
82 Internal::default_ranged_hash(),
83 eql, Internal::extract1st<std::pair<const Key, T> >(), a)
86 template<typename InputIterator>
87 unordered_map(InputIterator f, InputIterator l,
89 const hasher& hf = hasher(),
90 const key_equal& eql = key_equal(),
91 const allocator_type& a = allocator_type())
92 : Base (f, l, n, hf, Internal::mod_range_hashing(),
93 Internal::default_ranged_hash(),
94 eql, Internal::extract1st<std::pair<const Key, T> >(), a)
98 template<class Key, class T,
99 class Hash = hash<Key>,
100 class Pred = std::equal_to<Key>,
101 class Alloc = std::allocator<std::pair<const Key, T> >,
102 bool cache_hash_code = false>
103 class unordered_multimap
104 : public hashtable <Key, std::pair<const Key, T>,
106 Internal::extract1st<std::pair<const Key, T> >, Pred,
107 Hash, Internal::mod_range_hashing,
108 Internal::default_ranged_hash,
109 Internal::prime_rehash_policy,
110 cache_hash_code, false, false>
112 typedef hashtable <Key, std::pair<const Key, T>,
114 Internal::extract1st<std::pair<const Key, T> >, Pred,
115 Hash, Internal::mod_range_hashing,
116 Internal::default_ranged_hash,
117 Internal::prime_rehash_policy,
118 cache_hash_code, false, false>
122 typedef typename Base::size_type size_type;
123 typedef typename Base::hasher hasher;
124 typedef typename Base::key_equal key_equal;
125 typedef typename Base::allocator_type allocator_type;
128 unordered_multimap(size_type n = 10,
129 const hasher& hf = hasher(),
130 const key_equal& eql = key_equal(),
131 const allocator_type& a = allocator_type())
132 : Base (n, hf, Internal::mod_range_hashing(),
133 Internal::default_ranged_hash(),
134 eql, Internal::extract1st<std::pair<const Key, T> >(), a)
138 template<typename InputIterator>
139 unordered_multimap(InputIterator f, InputIterator l,
140 typename Base::size_type n = 0,
141 const hasher& hf = hasher(),
142 const key_equal& eql = key_equal(),
143 const allocator_type& a = allocator_type())
144 : Base (f, l, n, hf, Internal::mod_range_hashing(),
145 Internal::default_ranged_hash(),
146 eql, Internal::extract1st<std::pair<const Key, T> >(), a)
150 template<class Key, class T, class Hash, class Pred, class Alloc,
151 bool cache_hash_code>
153 swap(unordered_map<Key, T, Hash, Pred, Alloc, cache_hash_code>& x,
154 unordered_map<Key, T, Hash, Pred, Alloc, cache_hash_code>& y)
157 template<class Key, class T, class Hash, class Pred, class Alloc,
158 bool cache_hash_code>
160 swap(unordered_multimap<Key, T, Hash, Pred, Alloc, cache_hash_code>& x,
161 unordered_multimap<Key, T, Hash, Pred, Alloc, cache_hash_code>& y)
164 _GLIBCXX_END_NAMESPACE
167 #endif /* GNU_LIBSTDCXX_TR1_UNORDERED_MAP_ */