CACAO
unordered_set.hpp
Go to the documentation of this file.
1 /* src/future/unordered_set.hpp - future unordered_set library features
2 
3  Copyright (C) 1996-2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
25 
26 #ifndef FUTURE_UNORDERED_SET_HPP_
27 #define FUTURE_UNORDERED_SET_HPP_ 1
28 
29 #include "config.h"
30 
31 // get unordered_set
32 #if HAVE_STD_TR1_UNORDERED_SET
33 
34 #include <tr1/unordered_set>
35 
36 namespace cacao {
37 
38 namespace _future = std::tr1;
39 const std::size_t unordered_set_default_bucket_count = 10;
40 
41 } // end namespace cacao
42 
43 #elif HAVE_BOOST_UNORDERED_SET
44 
45 #include <boost/unordered_set.hpp>
46 
47 namespace cacao {
48 
49 namespace _future = boost;
50 const std::size_t unordered_set_default_bucket_count = boost::unordered::detail::default_bucket_count;
51 
52 } // end namespace cacao
53 
54 #else
55 #error "No implementation of unordered_set available"
56 #endif
57 
58 #include "future/future_hash.hpp"
59 
60 namespace cacao {
61 
62 #if 0
63 // we want this:
64 template<
65  class Key,
66  class Hash = cacao::hash<Key>,
67  class KeyEqual = std::equal_to<Key>,
68  class Allocator = std::allocator<Key>
69 > using unordered_set = public _future::unordered_set<Key,Hash,KeyEqual,Allocator>;
70 #endif
71 
72 template<
73  class Key,
74  class Hash = cacao::hash<Key>,
75  class KeyEqual = std::equal_to<Key>,
76  class Allocator = std::allocator<Key>
77 >
78 class unordered_set : public _future::unordered_set<Key,Hash,KeyEqual,Allocator> {
79  typedef _future::unordered_set<Key,Hash,KeyEqual,Allocator> _Base;
80 public:
81  typedef typename _Base::key_type key_type;
82  typedef typename _Base::value_type value_type;
83  typedef typename _Base::size_type size_type;
84  typedef typename _Base::difference_type difference_type;
85  typedef typename _Base::hasher hasher;
86  typedef typename _Base::key_equal key_equal;
87  typedef typename _Base::allocator_type allocator_type;
88  typedef typename _Base::reference reference;
89  typedef typename _Base::const_reference const_reference;
90  typedef typename _Base::pointer pointer;
91  typedef typename _Base::const_pointer const_pointer;
92  typedef typename _Base::iterator iterator;
93  typedef typename _Base::const_iterator const_iterator;
94  typedef typename _Base::local_iterator local_iterator;
95  typedef typename _Base::const_local_iterator const_local_iterator;
96 
97  explicit unordered_set(
99  const Hash& hash = Hash(),
100  const KeyEqual& equal = KeyEqual(),
101  const Allocator& alloc = Allocator())
102  : _Base(bucket_count, hash, equal, alloc) {}
103 
104  explicit unordered_set(
105  const Allocator& alloc)
106  : _Base(alloc) {}
107 
108  template<class InputIt>
110  InputIt first,
111  InputIt last,
113  const Hash& hash = Hash(),
114  const KeyEqual& equal = KeyEqual(),
115  const Allocator& alloc = Allocator())
116  : _Base(first, last, bucket_count, hash, equal, alloc) {}
117 
118  unordered_set(const unordered_set& other) : _Base(other) {}
119 
120  unordered_set(const unordered_set& other, const Allocator& alloc) : _Base(other,alloc) {}
121 
122 };
123 
124 template<
125  class Key,
126  class Hash = cacao::hash<Key>,
127  class KeyEqual = std::equal_to<Key>,
128  class Allocator = std::allocator<Key>
129 >
130 class unordered_multiset : public _future::unordered_multiset<Key,Hash,KeyEqual,Allocator> {
131  typedef _future::unordered_multiset<Key,Hash,KeyEqual,Allocator> _Base;
132 public:
133  typedef typename _Base::key_type key_type;
134  typedef typename _Base::value_type value_type;
135  typedef typename _Base::size_type size_type;
136  typedef typename _Base::difference_type difference_type;
137  typedef typename _Base::hasher hasher;
138  typedef typename _Base::key_equal key_equal;
139  typedef typename _Base::allocator_type allocator_type;
140  typedef typename _Base::reference reference;
141  typedef typename _Base::const_reference const_reference;
142  typedef typename _Base::pointer pointer;
143  typedef typename _Base::const_pointer const_pointer;
144  typedef typename _Base::iterator iterator;
145  typedef typename _Base::const_iterator const_iterator;
146  typedef typename _Base::local_iterator local_iterator;
147  typedef typename _Base::const_local_iterator const_local_iterator;
148 
151  const Hash& hash = Hash(),
152  const KeyEqual& equal = KeyEqual(),
153  const Allocator& alloc = Allocator())
154  : _Base(bucket_count, hash, equal, alloc) {}
155 
157  const Allocator& alloc)
158  : _Base(alloc) {}
159 
160  template<class InputIt>
162  InputIt first,
163  InputIt last,
165  const Hash& hash = Hash(),
166  const KeyEqual& equal = KeyEqual(),
167  const Allocator& alloc = Allocator())
168  : _Base(first, last, bucket_count, hash, equal, alloc) {}
169 
170  unordered_multiset(const unordered_multiset& other) : _Base(other) {}
171 
172  unordered_multiset(const unordered_multiset& other, const Allocator& alloc) : _Base(other,alloc) {}
173 
174 };
175 
176 } // end namespace cacao
177 #endif /* FUTURE_UNORDERED_SET_HPP_ */
178 
179 /*
180  * These are local overrides for various environment variables in Emacs.
181  * Please do not remove this and leave it at the end of the file, where
182  * Emacs will automagically detect them.
183  * ---------------------------------------------------------------------
184  * Local variables:
185  * mode: c++
186  * indent-tabs-mode: t
187  * c-basic-offset: 4
188  * tab-width: 4
189  * End:
190  * vim:noexpandtab:sw=4:ts=4:
191  */
const std::size_t unordered_set_default_bucket_count
_Base::difference_type difference_type
unordered_multiset(const Allocator &alloc)
unordered_set(size_type bucket_count=unordered_set_default_bucket_count, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
_Base::const_iterator const_iterator
_Base::const_reference const_reference
_Base::const_iterator const_iterator
_Base::hasher hasher
_Base::local_iterator local_iterator
unordered_set(InputIt first, InputIt last, size_type bucket_count=unordered_set_default_bucket_count, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
unordered_multiset(const unordered_multiset &other)
_Base::size_type size_type
_Base::allocator_type allocator_type
unordered_multiset(const unordered_multiset &other, const Allocator &alloc)
_Base::allocator_type allocator_type
_Base::const_pointer const_pointer
_Base::reference reference
_Base::value_type value_type
_future::unordered_set< Key, Hash, KeyEqual, Allocator > _Base
_Base::value_type value_type
unordered_multiset(InputIt first, InputIt last, size_type bucket_count=unordered_set_default_bucket_count, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
_Base::const_reference const_reference
unordered_set(const Allocator &alloc)
_Base::reference reference
unordered_set(const unordered_set &other, const Allocator &alloc)
_Base::const_local_iterator const_local_iterator
_Base::key_type key_type
_Base::iterator iterator
_Base::difference_type difference_type
_future::unordered_multiset< Key, Hash, KeyEqual, Allocator > _Base
_Base::size_type size_type
unordered_set(const unordered_set &other)
_Base::key_equal key_equal
_Base::key_equal key_equal
_Base::pointer pointer
_Base::const_pointer const_pointer
unordered_multiset(size_type bucket_count=unordered_set_default_bucket_count, const Hash &hash=Hash(), const KeyEqual &equal=KeyEqual(), const Allocator &alloc=Allocator())
_Base::const_local_iterator const_local_iterator
_Base::local_iterator local_iterator