home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 2.0 KB | 105 lines | [TEXT/MPS ] |
- // The C++ Booch Components (Version 2.1)
- // (C) Copyright 1990-1993 Grady Booch. All Rights Reserved..
- //
- // BCStac.h
- //
- // This file contains the declaration of the stack abstract base class
- // and its iterators.
-
- #ifndef BCSTAC_H
- #define BCSTAC_H 1
-
- #include "BCType.h"
-
- template<class Item>
- class BC_TStackActiveIterator;
-
- template<class Item>
- class BC_TStackPassiveIterator;
-
- template<class Item, class Structure>
- class BC_TPersist;
-
- // Stack abstact base class
-
- template<class Item>
- class BC_TStack {
- public:
-
- BC_TStack();
- BC_TStack(const BC_TStack<Item>&);
- virtual ~BC_TStack();
-
- virtual BC_TStack<Item>& operator=(const BC_TStack<Item>&);
- virtual BC_Boolean operator==(const BC_TStack<Item>&) const;
- BC_Boolean operator!=(const BC_TStack<Item>&) const;
-
- virtual void Clear() = 0;
- virtual void Push(const Item&) = 0;
- virtual void Pop() = 0;
-
- virtual BC_Index Depth() const = 0;
- virtual BC_Boolean IsEmpty() const = 0;
- virtual const Item& Top() const = 0;
- virtual Item& Top() = 0;
-
- protected:
-
- virtual void Purge() = 0;
- virtual void Add(const Item&) = 0;
- virtual BC_Index Cardinality() const = 0;
- virtual const Item& ItemAt(BC_Index) const = 0;
-
- virtual void Lock();
- virtual void Unlock();
-
- private:
-
- friend class BC_TStackActiveIterator<Item>;
- friend class BC_TStackPassiveIterator<Item>;
-
- friend class BC_TPersist<Item, BC_TStack<Item> >;
-
- };
-
- // Stack iterators
-
- template <class Item>
- class BC_TStackActiveIterator {
- public:
-
- BC_TStackActiveIterator(const BC_TStack<Item>&);
- ~BC_TStackActiveIterator();
-
- void Reset();
- BC_Boolean Next();
-
- BC_Boolean IsDone() const;
- const Item* CurrentItem() const;
- Item* CurrentItem();
-
- protected:
-
- const BC_TStack<Item>& fStack;
- BC_ExtendedIndex fIndex;
-
- };
-
- template <class Item>
- class BC_TStackPassiveIterator {
- public:
-
- BC_TStackPassiveIterator(const BC_TStack<Item>&);
- ~BC_TStackPassiveIterator();
-
- BC_Boolean Apply(BC_Boolean (*)(const Item&));
- BC_Boolean Apply(BC_Boolean (*)(Item&));
-
- protected:
-
- const BC_TStack<Item>& fStack;
-
- };
-
- #endif
-