2
/******************************************************************************
4
* DESCRIPTION: hashsets with reference counting
5
* COPYRIGHT : (C) 1999 Joris van der Hoeven
6
*******************************************************************************
7
* This software falls under the GNU general public license and comes WITHOUT
8
* ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
9
* If you don't have this file, write to the Free Software Foundation, Inc.,
10
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
11
******************************************************************************/
17
template<class T> class hashset;
18
template<class T> class hashset_iterator_rep;
19
template<class T> int N (hashset<T> h);
20
template<class T> ostream& operator << (ostream& out, hashset<T> h);
21
template<class T> bool operator <= (hashset<T> h1, hashset<T> h2);
23
template<class T> class hashset_rep: concrete_struct {
24
int size; // size of hashset (nr of entries)
25
int n; // nr of keys (a power of two)
26
int max; // mean number of entries per key
27
list<T>* a; // the array of entries
30
inline hashset_rep ():
31
size(0), n(1), max(1), a (new list<T>[1]) {}
32
inline hashset_rep(int n2, int max2=1):
33
size(0), n(n2), max(max2), a (new list<T>[n]) {}
34
inline ~hashset_rep () { delete[] a; }
41
friend class hashset<T>;
42
friend int N LESSGTR (hashset<T> h);
43
friend ostream& operator << LESSGTR (ostream& out, hashset<T> h);
44
friend bool operator <= LESSGTR (hashset<T> h1, hashset<T> h2);
45
friend class hashset_iterator_rep<T>;
48
template<class T> class hashset {
49
CONCRETE_TEMPLATE(hashset,T);
50
inline hashset (int n=1, int max=1):
51
rep (new hashset_rep<T>(n, max)) {}
54
CONCRETE_TEMPLATE_CODE(hashset,class,T);
56
template<class T> inline int N (hashset<T> h) { return h->size; }
57
template<class T> bool operator == (hashset<T> h1, hashset<T> h2);
58
template<class T> bool operator <= (hashset<T> h1, hashset<T> h2);
59
template<class T> bool operator < (hashset<T> h1, hashset<T> h2);
61
#include "hashset.cpp"
63
#endif // defined HASHSET_H