This commit was manufactured by cvs2svn to create branch
[official-gcc.git] / libstdc++-v3 / include / tr1 / unordered_set
blobe0f75f05c13a57a619c76829dc0befba222cf46a
1 // TR1 unordered_set -*- C++ -*-
3 // Copyright (C) 2005 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
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
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, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
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 
31  *  This is a TR1 C++ Library header. 
32  */
34 #ifndef GNU_LIBSTDCXX_TR1_UNORDERED_SET_
35 #define GNU_LIBSTDCXX_TR1_UNORDERED_SET_
37 #include <tr1/hashtable>
38 #include <tr1/functional>
39 #include <memory>
41 namespace std { namespace tr1 {
43 // XXX When we get typedef templates these class definitions will be unnecessary.
45 template <class Value,
46           class Hash = hash<Value>,
47           class Pred = std::equal_to<Value>,
48           class Alloc = std::allocator<Value>,
49           bool cache_hash_code = false>
50 class unordered_set
51   : public hashtable <Value, Value, Alloc,
52                       Internal::identity<Value>, Pred,
53                       Hash, Internal::mod_range_hashing, Internal::default_ranged_hash,
54                       Internal::prime_rehash_policy,
55                       cache_hash_code, false, true>
57   typedef hashtable <Value, Value, Alloc,
58                       Internal::identity<Value>, Pred,
59                       Hash, Internal::mod_range_hashing, Internal::default_ranged_hash,
60                       Internal::prime_rehash_policy,
61                       cache_hash_code, false, true>
62           Base;
64 public:
65   typedef typename Base::size_type size_type;
66   typedef typename Base::hasher hasher;
67   typedef typename Base::key_equal key_equal;
68   typedef typename Base::allocator_type allocator_type;
70   explicit unordered_set(size_type n = 10,
71                          const hasher& hf = hasher(),
72                          const key_equal& eql = key_equal(),
73                          const allocator_type& a = allocator_type())
74     : Base (n,
75             hf, Internal::mod_range_hashing(), Internal::default_ranged_hash(),
76             eql, Internal::identity<Value>(),
77             a)
78   { }
80   template <typename InputIterator>
81   unordered_set(InputIterator f, InputIterator l, 
82                 size_type n = 10,
83                 const hasher& hf = hasher(), 
84                 const key_equal& eql = key_equal(), 
85                 const allocator_type& a = allocator_type())
86     : Base (f, l,
87             n,
88             hf, Internal::mod_range_hashing(), Internal::default_ranged_hash(),
89             eql, Internal::identity<Value>(),
90             a)
91             { }
94 template <class Value,
95           class Hash = hash<Value>,
96           class Pred = std::equal_to<Value>,
97           class Alloc = std::allocator<Value>,
98           bool cache_hash_code = false>
99 class unordered_multiset
100   : public hashtable <Value, Value, Alloc,
101                       Internal::identity<Value>, Pred,
102                       Hash, Internal::mod_range_hashing, Internal::default_ranged_hash,
103                       Internal::prime_rehash_policy,
104                       cache_hash_code, false, false>
106   typedef hashtable <Value, Value, Alloc,
107                       Internal::identity<Value>, Pred,
108                       Hash, Internal::mod_range_hashing, Internal::default_ranged_hash,
109                       Internal::prime_rehash_policy,
110                       cache_hash_code, false, false>
111           Base;
113 public:
114   typedef typename Base::size_type size_type;
115   typedef typename Base::hasher hasher;
116   typedef typename Base::key_equal key_equal;
117   typedef typename Base::allocator_type allocator_type;
119   explicit unordered_multiset(size_type n = 10,
120                               const hasher& hf = hasher(),
121                               const key_equal& eql = key_equal(),
122                               const allocator_type& a = allocator_type())
123     : Base (n,
124             hf, Internal::mod_range_hashing(), Internal::default_ranged_hash(),
125             eql, Internal::identity<Value>(),
126             a)
127   { }
130   template <typename InputIterator>
131   unordered_multiset(InputIterator f, InputIterator l, 
132                      typename Base::size_type n = 0,
133                      const hasher& hf = hasher(), 
134                      const key_equal& eql = key_equal(), 
135                      const allocator_type& a = allocator_type())
136     : Base (f, l,
137             n,
138             hf, Internal::mod_range_hashing(), Internal::default_ranged_hash(),
139             eql, Internal::identity<Value>(),
140             a)
141   { }
144 template <class Value, class Hash, class Pred, class Alloc, bool cache_hash_code>
145 inline void swap (unordered_set<Value, Hash, Pred, Alloc, cache_hash_code>& x,
146                   unordered_set<Value, Hash, Pred, Alloc, cache_hash_code>& y)
148   x.swap(y);
151 template <class Value, class Hash, class Pred, class Alloc, bool cache_hash_code>
152 inline void swap (unordered_multiset<Value, Hash, Pred, Alloc, cache_hash_code>& x,
153                   unordered_multiset<Value, Hash, Pred, Alloc, cache_hash_code>& y)
155   x.swap(y);
158 } }
160 #endif /* GNU_LIBSTDCXX_TR1_UNORDERED_SET_ */