stl类queue

本文详细介绍了模板队列类的实现细节,包括默认构造函数、判断队列是否为空的方法、获取队列大小的方法、获取队列首尾元素的引用、删除队首元素以及在队尾插入元素等操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

template<class T,class container=deque<T> >
class queue
{
	public:
		explicit queue(container &cn=container());
		//dafault constructor initializes an empty queue
		//precondition :None
		//postcondition :An empty queue exists;
		bool empty()const;
		//determines if the queue is empty
		//precondition :None
		//postcondition :return true if the queue is empty
		//otherwise returns false
		size_type size()const;
		//determines the size of the queue ,the return type
		//size_type is an integral type.
		//precondition :None;
		//postcondition:return the number of items that are
		//currently in the queue
		T &front();
		//returns a reference to the first item of the queue
		//precondition :none
		//postcondition :the item is not removed from the queue
		T &back();
		//return a reference to the last item of the queue
		//precondition :none
		//postcondition :the item is not removed from the queue
		void pop();
		//removes the first item in the queue;
		//precondition :none
		//postcondition:the item at the front of the queue
		//is removed
		void push(const T &x);
		//Inserts an item to the back of the queue
		//precondition :none
		//postcondition :the item x is at the back of the queue.
};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值