home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) IBM Corp. 1992 */
-
- #ifndef _IKSBSEQ_H
- #define _IKSBSEQ_H
-
- #include <iglobals.h>
- #include <icursor.h>
-
- template < class Element, class Key, class ElementOps, class Base >
- class IWKSBagOnSeq {
- Base ivBase;
- class Cursor;
- friend class Cursor;
- public:
-
- class Cursor : public Base::Cursor {
- public:
- Cursor (IWKSBagOnSeq < Element, Key, ElementOps, Base > const& c)
- : Base::Cursor (c.ivBase) {}
- };
-
- IWKSBagOnSeq (INumber
- numberOfElements = 100,
- IBoundIndicator =
- IUnbounded);
-
- IWKSBagOnSeq (IWKSBagOnSeq < Element, Key, ElementOps, Base > const&);
-
- IWKSBagOnSeq < Element, Key, ElementOps, Base >& operator = (IWKSBagOnSeq < Element, Key, ElementOps, Base > const&);
-
- ~IWKSBagOnSeq ();
-
- Boolean add (Element const&);
-
- Boolean add (Element const&,
- ICursor&);
-
- void addAllFrom (IWKSBagOnSeq < 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;
-
- Key const& key (Element const&) const;
-
- Boolean containsElementWithKey (Key const&) const;
-
- Boolean containsAllKeysFrom (IWKSBagOnSeq < 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 (IWKSBagOnSeq < Element, Key, ElementOps, Base > const&,
- long (*comparisonFunction)
- (Element const&,
- Element const&)) const;
-
- protected:
-
- static Boolean removePredicate (Element const&, void*);
- Boolean locateKeyFwd (Key const&, ICursor&) const;
- Boolean locateKey (Key const&, ICursor&) const;
-
- static ElementOps cvElementOps;
-
- };
-
- #define IDefineGKeySortedBagOnGSequence(GSeq, GKeySortedBag) \
- template < class Element, class Key, class ElementOps > \
- class GKeySortedBag : \
- public IWKSBagOnSeq < Element, Key, ElementOps, \
- GSeq < Element, ElementOps > > { \
- public: \
- GKeySortedBag (INumber n = 100, IBoundIndicator b = IUnbounded) : \
- IWKSBagOnSeq < Element, Key, ElementOps, \
- GSeq < Element, ElementOps > > (n, b) {} \
- };
-
- #include <iksbseq.if>
-
- #ifdef __IBMCPP__
- #include <iksbseq.c>
- #endif
-
- #endif