home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / IDIOMS.ZIP / 7-3.C < prev    next >
C/C++ Source or Header  |  1991-12-04  |  771b  |  29 lines

  1. /* Copyright (c) 1992 by AT&T Bell Laboratories. */
  2. /* Advanced C++ Programming Styles and Idioms */
  3. /* James O. Coplien */
  4. /* All rights reserved. */
  5.  
  6. template <class T> class List {
  7. };
  8.  
  9. template <class ElementType> class Set {
  10. public:
  11.     void add(const ElementType& e) {
  12.         if (!rep.element(e)) rep.add(e); 
  13.     }
  14.     ElementType get() {
  15.         return rep.get;
  16.     }
  17.     void remove(const ElementType&);
  18.     int exists(const ElementType& e) const {
  19.         return rep.element(e);
  20.     }
  21.     Set<ElementType> Union(const Set<ElementType>&) const;
  22.     Set<ElementType> Intersection(const Set<ElementType>&)
  23.         const;
  24.     int size() const { return rep.size(); }
  25.     void sort() { rep.sort(); }
  26. private:
  27.     List<ElementType> rep;
  28. };
  29.