home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v1.zip / IBMCPP / IBMCLASS / IABAG.C < prev    next >
Text File  |  1993-09-22  |  2KB  |  41 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 >
  14. IBoolean IABag < Element >::
  15. operator == (IABag < Element > const& collection) const
  16. { if (numberOfElements () != collection.numberOfElements ())
  17.     return False;
  18.  
  19.   ICursor *cursor1 = newCursor ();
  20.   IBoolean result = True;
  21.   for (cursor1->setToFirst ();
  22.        cursor1->isValid ();
  23.        setToNextDifferentElement (*cursor1)) {
  24.     if (collection.numberOfOccurrences (elementAt (*cursor1)) !=
  25.         numberOfOccurrences (elementAt (*cursor1))) {
  26.       result = False;
  27.       break;
  28.     }
  29.   }
  30.   delete cursor1;
  31.   return result;
  32.  
  33. }
  34.  
  35. template < class Element >
  36. IBoolean IABag < Element >::
  37. operator != (IABag < Element > const& collection) const
  38. { return ! operator == (collection);
  39. }
  40.  
  41.