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 / SLBag.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>SLBag_h
  21. #ifdef __GNUG__
  22. #pragma interface
  23. #endif
  24. #define _<T>SLBag_h 1
  25.  
  26. #include "<T>.Bag.h"
  27. #include "<T>.SLList.h"
  28.  
  29. class <T>SLBag : public <T>Bag
  30. {
  31. protected:
  32.   <T>SLList     p;
  33.  
  34. public:
  35.                 <T>SLBag();
  36.                 <T>SLBag(const <T>SLBag&);
  37.  
  38.   inline Pix           add(<T&> item);
  39.   void          del(<T&> item);
  40.   void          remove(<T&>item);
  41.   inline int           contains(<T&> item);
  42.   int           nof(<T&> item);
  43.  
  44.   inline void          clear();
  45.  
  46.   inline Pix           first();
  47.   inline void          next(Pix& i);
  48.   inline <T>&          operator () (Pix i);
  49.   inline int           owns(Pix i);
  50.   Pix           seek(<T&> item, Pix from = 0);
  51.  
  52.   int           OK();
  53. };
  54.  
  55.  
  56. inline <T>SLBag::<T>SLBag() : p() { count = 0; }
  57.  
  58. inline <T>SLBag::<T>SLBag(const <T>SLBag& s) : p(s.p) { count = s.count; }
  59.  
  60. inline Pix <T>SLBag::first()
  61. {
  62.   return p.first();
  63. }
  64.  
  65. inline void <T>SLBag::next(Pix  & idx)
  66. {
  67.   p.next(idx);
  68. }
  69.  
  70. inline <T>& <T>SLBag::operator ()(Pix   idx)
  71. {
  72.   return p(idx);
  73. }
  74.  
  75. inline void <T>SLBag::clear()
  76. {
  77.   count = 0;  p.clear();
  78. }
  79.  
  80. inline int <T>SLBag::owns (Pix   idx)
  81. {
  82.   return p.owns(idx);
  83. }
  84.  
  85. inline Pix <T>SLBag::add(<T&> item)
  86. {
  87.   ++count;
  88.   return p.append(item);
  89. }
  90.  
  91. inline int <T>SLBag::contains(<T&> item)
  92. {
  93.   return seek(item) != 0;
  94. }
  95.  
  96. #endif
  97.