home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) IBM Corp. 1992 */
-
-
- template < class Element, class Key >
- INumber IAMap < Element, Key >::
- numberOfOccurrences (Element const& element) const
- { if (contains (element))
- return 1;
- else
- return 0;
- }
-
- template < class Element, class Key >
- Boolean IAMap < Element, Key >::
- locateNext (Element const&, ICursor& cursor) const
- { cursor.invalidate ();
- return False;
- }
-
- template < class Element, class Key >
- INumber IAMap < Element, Key >::
- removeAllOccurrences (Element const& element)
- { if (remove (element))
- return 1;
- else
- return 0;
- }
-
- template < class Element, class Key >
- Boolean IAMap < Element, Key >::
- operator == (IAMap < Element, Key > const& collection) const
- { return this->containsAllFrom (collection) &&
- collection.containsAllFrom (*this);
- }
-
- template < class Element, class Key >
- Boolean IAMap < Element, Key >::
- operator != (IAMap < Element, Key > const& collection) const
- { return ! operator == (collection);
- }
-
- template < class Element, class Key >
- void IAMap < Element, Key >::
- unionWith (IAMap < Element, Key > const& collection)
- { addAllFrom (collection);
- }
-
- template < class Element, class Key >
- void IAMap < Element, Key >::
- intersectionWith (IAMap < Element, Key > const& collection)
- { IAEqualityCollection < Element > const* env = &collection;
- removeAll (IAEqualityCollection < Element >::isNotContained, &env);
- }
-
- template < class Element, class Key >
- void IAMap < Element, Key >::
- differenceWith (IAMap < Element, Key > const& collection)
- { IAEqualityCollection < Element > const* env = &collection;
- removeAll (IAEqualityCollection < Element >::isContained, &env);
- }
-
- template < class Element, class Key >
- void IAMap < Element, Key >::
- addUnion (IAMap < Element, Key > const& collection1,
- IAMap < Element, Key > const& collection2)
- { addAllFrom (collection1);
- addAllFrom (collection2);
- }
-
- template < class Element, class Key >
- void IAMap < Element, Key >::
- addIntersection (IAMap < Element, Key > const& collection1,
- IAMap < Element, Key > const& collection2)
- { ICursor *cursor = collection1.newCursor ();
- forCursor (*cursor) {
- if (collection2.contains (collection1.elementAt (*cursor)))
- add (collection1.elementAt (*cursor));
- }
- delete cursor;
- }
-
- template < class Element, class Key >
- void IAMap < Element, Key >::
- addDifference (IAMap < Element, Key > const& collection1,
- IAMap < Element, Key > const& collection2)
- { ICursor *cursor = collection1.newCursor ();
- forCursor (*cursor) {
- if (! collection2.contains (collection1.elementAt (*cursor)))
- add (collection1.elementAt (*cursor));
- }
- delete cursor;
- }
-
- template < class Element, class Key >
- INumber IAMap < Element, Key >::
- numberOfElementsWithKey (Key const& key) const
- { if (containsElementWithKey (key))
- return 1;
- else
- return 0;
- }
-
- template < class Element, class Key >
- Boolean IAMap < Element, Key >::
- locateNextElementWithKey (Key const&, ICursor& cursor) const
- { cursor.invalidate ();
- return False;
- }
-
- template < class Element, class Key >
- INumber IAMap < Element, Key >::
- removeAllElementsWithKey (Key const& key)
- { if (removeElementWithKey (key))
- return 1;
- else
- return 0;
- }
-
- template < class Element, class Key >
- INumber IAMap < Element, Key >::
- numberOfDifferentKeys () const
- { return numberOfElements ();
- }
-
- template < class Element, class Key >
- Boolean IAMap < Element, Key >::
- setToNextWithDifferentKey (ICursor& cursor) const
- { return setToNext (cursor);
- }
-