moveStack.h
Go to the documentation of this file.
00001 #ifndef _MOVE_STACK_H
00002 #define _MOVE_STACK_H
00003 #include "osl/container/moveVector.h"
00004 #include "osl/stl/vector.h"
00005 #include <cassert>
00006 namespace osl
00007 {
00008   namespace container
00009   {
00014   class MoveStack
00015   {
00016     typedef vector<Move> vector_t;
00017     vector_t data;
00018   public:
00019     MoveStack();
00020     ~MoveStack();
00021 
00022     void reserve(size_t);
00023     void clear();
00024     void push(Move m) { data.push_back(m); }
00025     void pop() { data.pop_back(); }
00027     bool hasLastMove(size_t last=1) const { return size()>=last; }
00028     const Move lastMove(size_t last=1) const
00029     {
00030       const size_t index = data.size() - last;
00031       assert(index < data.size());
00032       return data[index];
00033     }
00034     size_t size() const { return data.size()-2; }
00038     void dump(size_t last_n=0) const;
00039     void dump(std::ostream&, size_t last_n=0) const;
00040     bool operator==(const MoveStack& r) const
00041     {
00042       return data == r.data;
00043     }
00044   };
00045 } // namespace container
00046   using container::MoveStack;
00047 } // namespace osl
00048 #endif // _MOVE_STACK_H
00049 // ;;; Local Variables:
00050 // ;;; mode:c++
00051 // ;;; c-basic-offset:2
00052 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines