home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / g++ / gen / CHSet.hP < prev    next >
Text File  |  1993-06-29  |  2KB  |  85 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, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19.  
  20. #ifndef _<T>CHSet_h
  21. #ifdef __GNUG__
  22. #pragma interface
  23. #endif
  24. #define _<T>CHSet_h 1
  25.  
  26. #include "<T>.Set.h"
  27. #include "<T>.CHNode.h"
  28.  
  29. class <T>CHSet : public <T>Set
  30. {
  31. protected:
  32.   <T>CHNode**   tab;
  33.   unsigned int  size;
  34.  
  35. public:
  36.                 <T>CHSet(unsigned int sz = DEFAULT_INITIAL_CAPACITY);
  37.                 <T>CHSet(<T>CHSet& a);
  38.                 ~<T>CHSet();
  39.  
  40.   Pix           add(<T&> item);
  41.   void          del(<T&> item);
  42.   int           contains(<T&> item);
  43.  
  44.   void          clear();
  45.  
  46.   Pix           first();
  47.   void          next(Pix& i);
  48.   <T>&          operator () (Pix i);
  49.   Pix           seek(<T&> item);
  50.  
  51.   void          operator |= (<T>CHSet& b);
  52.   void          operator -= (<T>CHSet& b);
  53.   void          operator &= (<T>CHSet& b);
  54.  
  55.   int           operator == (<T>CHSet& b);
  56.   int           operator != (<T>CHSet& b);
  57.   int           operator <= (<T>CHSet& b); 
  58.  
  59.   int           OK();
  60. };
  61.  
  62. inline <T>CHSet::~<T>CHSet()
  63. {
  64.   clear();
  65.   delete tab;
  66. }
  67.  
  68. inline int <T>CHSet::contains(<T&> key)
  69. {
  70.   return seek(key) != 0;
  71. }
  72.  
  73. inline <T>& <T>CHSet::operator () (Pix i)
  74. {
  75.   if (i == 0) error("null Pix");
  76.   return ((<T>CHNode*)i)->hd;
  77. }
  78.  
  79. inline int <T>CHSet::operator != (<T>CHSet& b)
  80. {
  81.   return ! ((*this) == b);
  82. }
  83.  
  84. #endif
  85.