xref: /386bsd/usr/include/nonstd/gnu/g++/gen/VOHSet.hP (revision a2142627)
1// This may look like C code, but it is really -*- C++ -*-
2/*
3Copyright (C) 1988 Free Software Foundation
4    written by Doug Lea (dl@rocky.oswego.edu)
5     based on code by Doug Schmidt
6
7This file is part of GNU CC.
8
9GNU CC is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY.  No author or distributor
11accepts responsibility to anyone for the consequences of using it
12or for whether it serves any particular purpose or works at all,
13unless he says so in writing.  Refer to the GNU CC General Public
14License for full details.
15
16Everyone is granted permission to copy, modify and redistribute
17GNU CC, but only under the conditions described in the
18GNU CC General Public License.   A copy of this license is
19supposed to have been given to you along with GNU CC so you
20can know your rights and responsibilities.  It should be in a
21file named COPYING.  Among other things, the copyright notice
22and this notice must be preserved on all copies.
23*/
24
25
26#ifndef _<T>VOHSet_h
27#ifdef __GNUG__
28#pragma once
29#pragma interface
30#endif
31#define _<T>VOHSet_h 1
32
33#include "<T>.Set.h"
34
35
36
37class <T>VOHSet : public <T>Set
38{
39  <T>*                  tab;
40  char*                 status;
41  int                   size;
42  int                   cnt; // keeps track of VALIDCELLs and DELETEDCELLs
43
44public:
45                        <T>VOHSet(int sz = DEFAULT_INITIAL_CAPACITY);
46                        <T>VOHSet(<T>VOHSet&);
47                        ~<T>VOHSet();
48
49  Pix           add(<T&> item);
50  void          del(<T&> item);
51  int           contains(<T&> item);
52
53  void          clear();
54
55  Pix           first();
56  void          next(Pix& i);
57  <T>&          operator () (Pix i);
58  Pix           seek(<T&> item);
59
60  void          operator |= (<T>VOHSet& b);
61  void          operator -= (<T>VOHSet& b);
62  void          operator &= (<T>VOHSet& b);
63
64  int           operator == (<T>VOHSet& b);
65  int           operator != (<T>VOHSet& b);
66  int           operator <= (<T>VOHSet& b);
67
68  int           capacity();
69  void          resize(int newsize = 0);
70
71  int           OK();
72};
73
74
75#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
76
77inline <T>VOHSet::~<T>VOHSet()
78{
79  delete [size] tab;
80  delete status;
81}
82
83
84inline int <T>VOHSet::contains(int  key)
85{
86  return seek(key) != 0;
87}
88
89
90inline <T>& <T>VOHSet::operator () (Pix p)
91{
92  if (p == 0) error("null Pix");
93  return *((<T>*)p);
94}
95
96#endif
97#endif
98