home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD 24 / PCPLUS115.iso / pcplus / tclite / include / stack.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-28  |  1.4 KB  |  39 lines

  1. #ifndef    STACK_H
  2. #define    STACK_H
  3.  
  4. #include "ordcltn.h"
  5.  
  6. extern const Class class_Stack;
  7.  
  8. class Stack : public SeqCltn {
  9.     OrderedCltn contents;
  10. public:
  11.     Stack(unsigned size =CLTN_DEFAULT_CAPACITY) : contents(size) {}
  12.     Stack(const Stack& s) : contents(*((OrderedCltn*)&s)) {}
  13.     bool operator==(const Stack& s) const
  14.         { return contents == ((Stack*)&s)->contents; }
  15.     bool operator!=(const Stack& s) const { return !(*this==s); }
  16.     void operator=(const Stack& s)    { contents = ((Stack*)&s)->contents; }
  17.     Object*& operator[](int i) const     { return contents.at(size()-i-1); }
  18.     void push(const Object& ob)    { contents.addLast(ob); }
  19.     Object* pop()            { return contents.removeLast(); }
  20.     Object* top() const          { return contents.last(); }
  21.     virtual Object* add(const Object& ob);
  22.     virtual Collection& addContentsTo(Collection& cltn) const;
  23.     virtual Object*& at(int i) const;
  24.     virtual unsigned capacity() const;
  25.     virtual void deepenShallowCopy();
  26.     virtual unsigned hash() const;
  27.     virtual const Class* isA() const;
  28.     virtual bool isEmpty() const;
  29.     virtual bool isEqual(const Object& ob) const;
  30.     virtual Object* last() const;
  31.     virtual void printOn(ostream& strm) const;
  32.     virtual void reSize(unsigned newSize);
  33.     virtual Object* removeLast();
  34.     virtual unsigned size() const;
  35.     virtual const Class* species() const;
  36. };
  37.  
  38. #endif
  39.