コード例 #1
0
ファイル: Max_Queue.cpp プロジェクト: bravepam/CLRS
	T pop()
	{//出队
		if (B.empty())
		{//若B空,则队首元素应该在A的栈底
			while (!A.empty())//将A中元素全部压入B
				B.push(A.pop());
		}
		return B.pop();//出B栈
	}
コード例 #2
0
	void pop()
	{
		if (head.empty())
		{
			while (!tail.empty())
			{
				head.push(tail.top());
				tail.pop();
			}
		}
		head.pop();
	}
コード例 #3
0
ファイル: Max_Queue.cpp プロジェクト: bravepam/CLRS
	void push(const T & val) { A.push(val); }
コード例 #4
0
	void push(const int& x)
	{
		tail.push(x);
	}