xref: /386bsd/usr/include/nonstd/gnu/g++/gen/VHBag.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
6This file is part of GNU CC.
7
8GNU CC is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY.  No author or distributor
10accepts responsibility to anyone for the consequences of using it
11or for whether it serves any particular purpose or works at all,
12unless he says so in writing.  Refer to the GNU CC General Public
13License for full details.
14
15Everyone is granted permission to copy, modify and redistribute
16GNU CC, but only under the conditions described in the
17GNU CC General Public License.   A copy of this license is
18supposed to have been given to you along with GNU CC so you
19can know your rights and responsibilities.  It should be in a
20file named COPYING.  Among other things, the copyright notice
21and this notice must be preserved on all copies.
22*/
23
24
25#ifndef _<T>VHBag_h
26#ifdef __GNUG__
27#pragma once
28#pragma interface
29#endif
30#define _<T>VHBag_h 1
31
32#include "<T>.Bag.h"
33
34
35class <T>VHBag : public <T>Bag
36{
37protected:
38  <T>*          tab;
39  char*         status;
40  unsigned int  size;
41
42public:
43                <T>VHBag(unsigned int sz = DEFAULT_INITIAL_CAPACITY);
44                <T>VHBag(<T>VHBag& a);
45                ~<T>VHBag();
46
47  Pix           add(<T&> item);
48  void          del(<T&> item);
49  void          remove(<T&>item);
50  int           nof(<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, Pix from = 0);
59
60  int           capacity();
61  void          resize(unsigned int newsize = 0);
62
63  int           OK();
64};
65
66#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
67
68inline <T>VHBag::~<T>VHBag()
69{
70  delete [size] tab;
71  delete status;
72}
73
74
75inline int <T>VHBag::capacity()
76{
77  return size;
78}
79
80inline int <T>VHBag::contains(<T&> key)
81{
82  return seek(key) != 0;
83}
84
85inline <T>& <T>VHBag::operator () (Pix i)
86{
87  if (i == 0) error("null Pix");
88  return *((<T>*)i);
89}
90
91#endif
92#endif
93