home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) IBM Corp. 1992 */
-
- #ifndef _IMAPKS_H
- #define _IMAPKS_H
-
- #include <iglobals.h>
- #include <icursor.h>
-
- template < class Element, class Key, class ElementOps, class Base >
- class IWMapOnKeySet {
- Base ivBase;
- class Cursor;
- friend class Cursor;
- public:
-
- class Cursor : public Base::Cursor {
- public:
- Cursor (IWMapOnKeySet
- < Element, Key, ElementOps, Base > const& c)
- : Base::Cursor (c.ivBase) {}
- };
-
- IWMapOnKeySet (INumber
- numberOfElements = 100,
- IBoundIndicator =
- IUnbounded);
-
- IWMapOnKeySet (IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
-
- IWMapOnKeySet < Element, Key, ElementOps, Base >& operator = (IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
-
- ~IWMapOnKeySet ();
-
- Boolean add (Element const&);
-
- Boolean add (Element const&,
- ICursor&);
-
- void addAllFrom (IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
-
- Element const& elementAt (ICursor const&) const;
-
- Element& elementAt (ICursor const&);
-
- Element const& anyElement () const;
-
- void removeAt (ICursor const&);
-
- INumber removeAll (Boolean (*property)
- (Element const&, void*),
- void* additionalArgument = 0);
-
- void replaceAt (ICursor const&,
- Element const&);
-
- void removeAll ();
-
- Boolean isBounded () const;
-
- INumber maxNumberOfElements () const;
-
- INumber numberOfElements () const;
-
- Boolean isEmpty () const;
-
- Boolean isFull () const;
-
- ICursor* newCursor () const;
-
- Boolean setToFirst (ICursor&) const;
-
- Boolean setToNext (ICursor&) const;
-
- Boolean allElementsDo (Boolean (*function)
- (Element&, void*),
- void* additionalArgument = 0);
-
- Boolean allElementsDo (IIterator <Element>&);
-
- Boolean allElementsDo (Boolean (*function)
- (Element const&, void*),
- void* additionalArgument = 0)
- const;
-
- Boolean allElementsDo (IConstantIterator
- <Element>&) const;
-
- Boolean contains (Element const&) const;
-
- Boolean containsAllFrom (IWMapOnKeySet < Element, Key, ElementOps, Base > const&) const;
-
- Boolean locate (Element const&, ICursor&)
- const;
-
- Boolean locateOrAdd (Element const&);
-
- Boolean locateOrAdd (Element const&,
- ICursor&);
-
- Boolean remove (Element const&);
-
- Boolean operator == (IWMapOnKeySet < Element, Key, ElementOps, Base > const&) const;
-
- Boolean operator != (IWMapOnKeySet < Element, Key, ElementOps, Base > const&) const;
-
- void unionWith (IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
-
- void intersectionWith (IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
-
- void differenceWith (IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
-
- void addUnion (IWMapOnKeySet < Element, Key, ElementOps, Base > const&,
- IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
-
- void addIntersection (IWMapOnKeySet < Element, Key, ElementOps, Base > const&,
- IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
-
- void addDifference (IWMapOnKeySet < Element, Key, ElementOps, Base > const&,
- IWMapOnKeySet < Element, Key, ElementOps, Base > const&);
-
- Key const& key (Element const&) const;
-
- Boolean containsElementWithKey (Key const&) const;
-
- Boolean containsAllKeysFrom (IWMapOnKeySet < Element, Key, ElementOps, Base > const&) const;
-
- Boolean locateElementWithKey (Key const&, ICursor&)
- const;
-
- Boolean replaceElementWithKey (Element const&);
-
- Boolean replaceElementWithKey (Element const&,
- ICursor&);
-
- Boolean locateOrAddElementWithKey (Element const&);
-
- Boolean locateOrAddElementWithKey (Element const&,
- ICursor&);
-
- Boolean addOrReplaceElementWithKey (Element const&);
-
- Boolean addOrReplaceElementWithKey (Element const&,
- ICursor&);
-
- Boolean removeElementWithKey (Key const&);
-
- Element const& elementWithKey (Key const&) const;
-
- Element& elementWithKey (Key const&);
-
- protected:
-
- static Boolean isContained (Element const&, void* env);
- static Boolean isNotContained (Element const&, void* env);
-
- static ElementOps cvElementOps;
-
- };
-
- #define IDefineGMapOnGKeySet(GKeySet, GMap) \
- template < class Element, class Key, class ElementOps > \
- class GMap : \
- public IWMapOnKeySet \
- < Element, Key, ElementOps, \
- GKeySet < Element, Key, ElementOps > > { \
- public: \
- GMap (INumber n = 100, IBoundIndicator b = IUnbounded) : \
- IWMapOnKeySet \
- < Element, Key, ElementOps, \
- GKeySet < Element, Key, ElementOps > > (n, b) {} \
- };
-
- #include <imapks.if>
-
- #ifdef __IBMCPP__
- #include <imapks.c>
- #endif
-
- #endif