home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / g__lib / set.hp < prev    next >
Text File  |  1993-07-23  |  2KB  |  80 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 GNU CC.
  7.  
  8. GNU CC is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY.  No author or distributor
  10. accepts responsibility to anyone for the consequences of using it
  11. or for whether it serves any particular purpose or works at all,
  12. unless he says so in writing.  Refer to the GNU CC General Public
  13. License for full details.
  14.  
  15. Everyone is granted permission to copy, modify and redistribute
  16. GNU CC, but only under the conditions described in the
  17. GNU CC General Public License.   A copy of this license is
  18. supposed to have been given to you along with GNU CC so you
  19. can know your rights and responsibilities.  It should be in a
  20. file named COPYING.  Among other things, the copyright notice
  21. and this notice must be preserved on all copies.  
  22. */
  23.  
  24.  
  25. #ifndef _<T>Set_h
  26. #pragma once
  27. #define _<T>Set_h 1
  28.  
  29. #include <Pix.h>
  30. #include "<T>.defs.h"
  31.  
  32. class <T>Set
  33. {
  34. protected:
  35.  
  36.   int                   count;
  37.  
  38. public:
  39.   int                   length();                // current number of items
  40.   int                   empty();
  41.  
  42.   virtual Pix           add(<T&> item);          // add item; return Pix
  43.   virtual void          del(<T&> item);          // delete item
  44.   virtual int           contains(<T&> item);     // is item in set?
  45.  
  46.   virtual void          clear();                 // delete all items
  47.  
  48.   virtual Pix           first();                 // Pix of first item or 0
  49.   virtual void          next(Pix& i);            // advance to next or 0
  50.   virtual <T>&          operator () (Pix i);     // access item at i
  51.  
  52.   virtual int           owns(Pix i);             // is i a valid Pix  ?
  53.   virtual Pix           seek(<T&> item);         // Pix of item
  54.  
  55.   void                  operator |= (<T>Set& b); // add all items in b
  56.   void                  operator -= (<T>Set& b); // delete items also in b
  57.   void                  operator &= (<T>Set& b); // delete items not in b
  58.  
  59.   int                   operator == (<T>Set& b);
  60.   int                   operator != (<T>Set& b);
  61.   int                   operator <= (<T>Set& b); 
  62.  
  63.   void                  error(char* msg);
  64.   virtual int           OK();                    // rep invariant
  65. };
  66.  
  67.  
  68. inline int <T>Set::length()
  69. {
  70.   return count;
  71. }
  72.  
  73. inline int <T>Set::empty()
  74. {
  75.   return count == 0;
  76. }
  77.  
  78.  
  79. #endif
  80.