~ubuntu-branches/ubuntu/quantal/texmacs/quantal

« back to all changes in this revision

Viewing changes to src/Kernel/Containers/hashset.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Atsuhito KOHDA, Kamaraju Kusumanchi, kohda
  • Date: 2008-04-06 15:11:41 UTC
  • mfrom: (1.1.7 upstream) (4.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080406151141-w0sg20jnv86mlt6f
Tags: 1:1.0.6.14-1
[Kamaraju Kusumanchi <kamaraju@gmail.com>]
* New upstream release
* 01_american.dpatch is updated
* Since thread support in guile-1.8 is now disabled, the segmentation faults
  should not arise anymore. More info at #439923. (Closes: #450499, #458685)
[kohda]
* This version fixed menu problem.  (Closes: #447083)
* Reverted orig.tar.gz to the upstream tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/******************************************************************************
 
3
* MODULE     : hashset.hpp
 
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
******************************************************************************/
 
12
 
 
13
#ifndef HASHSET_H
 
14
#define HASHSET_H
 
15
#include "list.hpp"
 
16
 
 
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);
 
22
 
 
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
 
28
 
 
29
public:
 
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; }
 
35
 
 
36
  bool contains (T x);
 
37
  void resize (int n);
 
38
  void insert (T x);
 
39
  void remove (T x);
 
40
 
 
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>;
 
46
};
 
47
 
 
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)) {}
 
52
  operator tree ();
 
53
};
 
54
CONCRETE_TEMPLATE_CODE(hashset,class,T);
 
55
 
 
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);
 
60
 
 
61
#include "hashset.cpp"
 
62
 
 
63
#endif // defined HASHSET_H