home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IAREL.C < prev    next >
Text File  |  1993-09-22  |  2KB  |  55 lines

  1. /*******************************************************************************
  2. *                                                                              *
  3. * COPYRIGHT:                                                                   *
  4. *   IBM C/C++ Tools Version 2.01 - Collection Class Library                    *
  5. *   Licensed Materials - Property of IBM                                       *
  6. *   (C) Copyright IBM Corporation 1992, 1993                                   *
  7. *   All Rights Reserved                                                        *
  8. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  9. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  10. *                                                                              *
  11. *******************************************************************************/
  12.  
  13. template < class Element, class Key >
  14. INumber IARelation < Element, Key >::
  15. numberOfOccurrences (Element const& element) const
  16. { if (contains (element))
  17.     return 1;
  18.   else
  19.     return 0;
  20. }
  21.  
  22. template < class Element, class Key >
  23. IBoolean IARelation < Element, Key >::
  24. locateNext (Element const&, ICursor& cursor) const
  25. { elementAt (cursor); // just for precondition checking
  26.   cursor.invalidate ();
  27.   return False;
  28. }
  29.  
  30. template < class Element, class Key >
  31. INumber IARelation < Element, Key >::
  32. removeAllOccurrences (Element const& element)
  33. { if (remove (element))
  34.     return 1;
  35.   else
  36.     return 0;
  37. }
  38.  
  39. template < class Element, class Key >
  40. IBoolean IARelation < Element, Key >::
  41. operator == (IARelation < Element, Key > const& collection) const
  42. { if (numberOfElements () != collection.numberOfElements ())
  43.     return False;
  44.  
  45.   return containsAllFrom (collection);
  46.  
  47. }
  48.  
  49. template < class Element, class Key >
  50. IBoolean IARelation < Element, Key >::
  51. operator != (IARelation < Element, Key > const& collection) const
  52. { return ! operator == (collection);
  53. }
  54.  
  55.