1 /* src/toolbox/hashtable.hpp - hashtable classes
3 Copyright (C) 2009, 2011
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 Copyright (C) 2009 Theobroma Systems Ltd.
7 This file is part of CACAO.
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2, or (at
12 your option) any later version.
14 This program is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27 #ifndef _HASHTABLE_HPP
28 #define _HASHTABLE_HPP
34 #include <tr1/unordered_map>
38 * Default hashing function for hashtable implementation.
40 template<class T> class Hasher {
46 * Hashtable implementation.
48 template<class Key, class T,
49 class Hash = Hasher<Key>,
50 class Pred = std::equal_to<Key> >
52 protected std::tr1::unordered_map<Key,T,Hash,Pred> {
55 Hashtable(size_t n) : std::tr1::unordered_map<Key,T,Hash,Pred>(n) {}
57 // Make iterator of TR1 unordered map visible.
58 using std::tr1::unordered_map<Key,T,Hash,Pred>::iterator;
60 // Make functions of TR1 unordered map visible.
61 using std::tr1::unordered_map<Key,T,Hash,Pred>::end;
62 using std::tr1::unordered_map<Key,T,Hash,Pred>::find;
63 using std::tr1::unordered_map<Key,T,Hash,Pred>::insert;
67 // Required by LockableHashtable.
68 #include "threads/mutex.hpp"
72 * Hashtable implementation with a Mutex.
74 template<class Key, class T,
75 class Hash = Hasher<Key>,
76 class Pred = std::equal_to<Key> >
77 class LockableHashtable :
78 public Hashtable<Key,T,Hash,Pred>,
82 LockableHashtable(size_t n) : Hashtable<Key,T,Hash,Pred>(n) {}
87 #endif /* _HASHTABLE_HPP */
91 * These are local overrides for various environment variables in Emacs.
92 * Please do not remove this and leave it at the end of the file, where
93 * Emacs will automagically detect them.
94 * ---------------------------------------------------------------------
101 * vim:noexpandtab:sw=4:ts=4: