template<class T,class Container=deque<T>>
class stack
{
public:
explicit stack(const Container &cnt =Container());
//default constructor ;initializes an empty stack
//precondition :none
//postcondition :an empty array exist
bool empty()const;
//determines whether the stack is empty
//precondition :none
//postcondition :returns true if the stack is emtpy
//otherwise returns false
size_type size()const;
//determinate the size of the stack.the return type
//size_type is an integral type
//precondition :none
//postcondition :returns the number of items that
//are currents in the stack
T &top();
//returns a reference to the top of the stack
//precondition None;
//postcondition :the item remains on the stack;
void pop();
//removes the top item in the stack
//precondition :none
//postcondition :the items most recently added
//is removed from the stack
void push();
//adds an items to the top of the stack
//precondition :none
//postcondition :Item x is the top of the stack
};
stl类stack
最新推荐文章于 2024-10-10 13:15:22 发布