home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) IBM Corp. 1992 */
-
- #ifndef _IRELKB_H
- #define _IRELKB_H
-
- #include <iglobals.h>
- #include <icursor.h>
-
- template < class Element, class Key, class ElementOps, class Base >
- class IWRelOnKeyBag {
- Base ivBase;
- class Cursor;
- friend class Cursor;
- public:
-
- class Cursor : public Base::Cursor {
- public:
- Cursor (IWRelOnKeyBag < Element, Key, ElementOps, Base > const& c)
- : Base::Cursor (c.ivBase) {}
- };
-
- IWRelOnKeyBag (INumber
- numberOfElements = 100,
- IBoundIndicator =
- IUnbounded);
-
- IWRelOnKeyBag (IWRelOnKeyBag < Element, Key, ElementOps, Base > const&);
-
- IWRelOnKeyBag < Element, Key, ElementOps, Base >& operator = (IWRelOnKeyBag < Element, Key, ElementOps, Base > const&);
-
- ~IWRelOnKeyBag ();
-
- Boolean add (Element const&);
-
- Boolean add (Element const&,
- ICursor&);
-
- void addAllFrom (IWRelOnKeyBag < 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 (IWRelOnKeyBag < 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 == (IWRelOnKeyBag < Element, Key, ElementOps, Base > const&) const;
-
- Boolean operator != (IWRelOnKeyBag < Element, Key, ElementOps, Base > const&) const;
-
- void unionWith (IWRelOnKeyBag < Element, Key, ElementOps, Base > const&);
-
- void intersectionWith (IWRelOnKeyBag < Element, Key, ElementOps, Base > const&);
-
- void differenceWith (IWRelOnKeyBag < Element, Key, ElementOps, Base > const&);
-
- void addUnion (IWRelOnKeyBag < Element, Key, ElementOps, Base > const&,
- IWRelOnKeyBag < Element, Key, ElementOps, Base > const&);
-
- void addIntersection (IWRelOnKeyBag < Element, Key, ElementOps, Base > const&,
- IWRelOnKeyBag < Element, Key, ElementOps, Base > const&);
-
- void addDifference (IWRelOnKeyBag < Element, Key, ElementOps, Base > const&,
- IWRelOnKeyBag < Element, Key, ElementOps, Base > const&);
-
- Key const& key (Element const&) const;
-
- Boolean containsElementWithKey (Key const&) const;
-
- Boolean containsAllKeysFrom (IWRelOnKeyBag < 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&);
-
- INumber numberOfElementsWithKey (Key const&) const;
-
- Boolean locateNextElementWithKey (Key const&,
- ICursor&) const;
-
- INumber removeAllElementsWithKey (Key const&);
-
- INumber numberOfDifferentKeys () const;
-
- Boolean setToNextWithDifferentKey (ICursor&) const;
-
- void removeFirst ();
-
- void removeLast ();
-
- void removeAtPosition (IPosition);
-
- Element const& firstElement () const;
-
- Element const& lastElement () const;
-
- Element const& elementAtPosition (IPosition) const;
-
- Boolean setToLast (ICursor&) const;
-
- Boolean setToPrevious (ICursor&) const;
-
- void setToPosition (IPosition,
- ICursor&) const;
-
- Boolean isFirst (ICursor const&) const;
-
- Boolean isLast (ICursor const&) const;
-
- long compare (IWRelOnKeyBag < Element, Key, ElementOps, Base > const&,
- long (*comparisonFunction)
- (Element const&,
- Element const&)) const;
-
- protected:
-
- static Boolean isContained (Element const&, void* env);
- static Boolean isNotContained (Element const&, void* env);
-
- static ElementOps cvElementOps;
-
- };
-
- #define IDefineGRelationOnGKeyBag(GKeyBag, GRelation) \
- template < class Element, class Key, class ElementOps > \
- class GRelation : \
- public IWRelOnKeyBag \
- < Element, Key, ElementOps, \
- GKeyBag < Element, Key, ElementOps > > { \
- public: \
- GRelation (INumber n = 100, IBoundIndicator b = IUnbounded) : \
- IWRelOnKeyBag \
- < Element, Key, ElementOps, \
- GKeyBag < Element, Key, ElementOps > > (n, b) {} \
- };
-
- #include <irelkb.if>
-
- #ifdef __IBMCPP__
- #include <irelkb.c>
- #endif
-
- #endif