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