home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) IBM Corp. 1992 */
-
-
- template < class Element, class Key >
- INumber IAKeySortedSet < Element, Key >::
- numberOfElementsWithKey (Key const& key) const
- { if (containsElementWithKey (key))
- return 1;
- else
- return 0;
- }
-
- template < class Element, class Key >
- Boolean IAKeySortedSet < Element, Key >::
- locateNextElementWithKey (Key const&, ICursor& cursor) const
- { cursor.invalidate ();
- return False;
- }
-
- template < class Element, class Key >
- INumber IAKeySortedSet < Element, Key >::
- removeAllElementsWithKey (Key const& key)
- { if (removeElementWithKey (key))
- return 1;
- else
- return 0;
- }
-
- template < class Element, class Key >
- INumber IAKeySortedSet < Element, Key >::
- numberOfDifferentKeys () const
- { return numberOfElements ();
- }
-
- template < class Element, class Key >
- Boolean IAKeySortedSet < Element, Key >::
- setToNextWithDifferentKey (ICursor& cursor) const
- { return setToNext (cursor);
- }
-
- template < class Element, class Key >
- long IAKeySortedSet < Element, Key >::
- compare (IAKeySortedSet < Element, Key > const& collection,
- long (*comparisonFunction) (Element const&, Element const&)) const
- { long result = 0;
- ICursor *thisCursor = newCursor ();
- ICursor *collectionCursor = collection.newCursor ();
-
- for (thisCursor->setToFirst (), collectionCursor->setToFirst ();
- result == 0 && thisCursor->isValid () && collectionCursor->isValid ();
- thisCursor->setToNext (), collectionCursor->setToNext ()) {
- result = (*comparisonFunction) (this->elementAt (*thisCursor),
- collection.elementAt (*collectionCursor));
- }
-
- if (result == 0) {
- if (thisCursor->isValid () && ! collectionCursor->isValid ())
- result = 1;
- else if (! thisCursor->isValid () && collectionCursor->isValid ())
- result = -1;
- else {
- }
- }
- delete thisCursor;
- delete collectionCursor;
-
- return result;
- }
-