home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) IBM Corp. 1992 */
-
- #ifndef _IDEQSEQ_H
- #define _IDEQSEQ_H
-
- #include <iglobals.h>
- #include <icursor.h>
-
- template < class Element, class ElementOps, class Base >
- class IWDequeOnSeq {
- Base ivBase;
- class Cursor;
- friend class Cursor;
- public:
-
- class Cursor : public Base::Cursor {
- public:
- Cursor (IWDequeOnSeq < Element, ElementOps, Base > const& c)
- : Base::Cursor (c.ivBase) {}
- };
-
- IWDequeOnSeq (INumber
- numberOfElements = 100,
- IBoundIndicator =
- IUnbounded);
-
- IWDequeOnSeq (IWDequeOnSeq < Element, ElementOps, Base > const&);
-
- IWDequeOnSeq < Element, ElementOps, Base >& operator = (IWDequeOnSeq < Element, ElementOps, Base > const&);
-
- ~IWDequeOnSeq ();
-
- Boolean add (Element const&);
-
- Boolean add (Element const&,
- ICursor&);
-
- void addAllFrom (IWDequeOnSeq < Element, 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;
-
- 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 (IWDequeOnSeq < Element, ElementOps, Base > const&,
- long (*comparisonFunction)
- (Element const&,
- Element const&)) const;
-
- void addAsFirst (Element const&);
-
- void addAsFirst (Element const&,
- ICursor&);
-
- void addAsLast (Element const&);
-
- void addAsLast (Element const&,
- ICursor&);
-
- void addAsNext (Element const&,
- ICursor&);
-
- void addAsPrevious (Element const&,
- ICursor&);
-
- void addAtPosition (IPosition,
- Element const&);
-
- void addAtPosition (IPosition,
- Element const&,
- ICursor&);
-
- void sort (long (*comparisonFunction)
- (Element const&,
- Element const&));
-
- };
-
- #define IDefineGDequeOnGSequence(GSeq, GDeque) \
- template < class Element, class ElementOps > \
- class GDeque : \
- public IWDequeOnSeq < Element, ElementOps, \
- GSeq < Element, ElementOps > > { \
- public: \
- GDeque (INumber n = 100, IBoundIndicator b = IUnbounded) : \
- IWDequeOnSeq < Element, ElementOps, \
- GSeq < Element, ElementOps > > (n, b) {} \
- };
-
- #include <ideqseq.if>
-
- #endif