home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / libg++-2.7.1-bin.lha / lib / g++-include / gen / VHSet.hP < prev    next >
Text File  |  1996-10-12  |  2KB  |  97 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18.  
  19.  
  20. #ifndef _<T>VHSet_h
  21. #ifdef __GNUG__
  22. #pragma interface
  23. #endif
  24. #define _<T>VHSet_h 1
  25.  
  26. #include "<T>.Set.h"
  27.  
  28.  
  29.  
  30. class <T>VHSet : public <T>Set
  31. {
  32. protected:
  33.   <T>*          tab;
  34.   char*         status;
  35.   unsigned int  size;
  36.  
  37. public:
  38.                 <T>VHSet(unsigned int sz = DEFAULT_INITIAL_CAPACITY);
  39.                 <T>VHSet(<T>VHSet& a);
  40.   inline               ~<T>VHSet();
  41.  
  42.   Pix           add(<T&> item);
  43.   void          del(<T&> item);
  44.   inline int           contains(<T&> item);
  45.  
  46.   void          clear();
  47.  
  48.   Pix           first();
  49.   void          next(Pix& i);
  50.   inline <T>&          operator () (Pix i);
  51.   Pix           seek(<T&> item);
  52.  
  53.   void          operator |= (<T>VHSet& b);
  54.   void          operator -= (<T>VHSet& b);
  55.   void          operator &= (<T>VHSet& b);
  56.  
  57.   int           operator == (<T>VHSet& b);
  58.   int           operator != (<T>VHSet& b);
  59.   int           operator <= (<T>VHSet& b); 
  60.  
  61.   int           capacity();
  62.   void          resize(unsigned int newsize = 0);
  63.  
  64.   int           OK();
  65. };
  66.  
  67.  
  68. inline <T>VHSet::~<T>VHSet()
  69. {
  70.   delete [] tab;
  71.   delete status;
  72. }
  73.  
  74.  
  75. inline int <T>VHSet::capacity()
  76. {
  77.   return size;
  78. }
  79.  
  80. inline int <T>VHSet::contains(<T&> key)
  81. {
  82.   return seek(key) != 0;
  83. }
  84.  
  85. inline <T>& <T>VHSet::operator () (Pix i)
  86. {
  87.   if (i == 0) error("null Pix");
  88.   return *((<T>*)i);
  89. }
  90.  
  91. inline int <T>VHSet::operator != (<T>VHSet& b)
  92. {
  93.   return ! ((*this) == b);
  94. }
  95.  
  96. #endif
  97.