Sicily 2302. Queue Implementation Using a Circular
来源:互联网 发布:职业调查报告网络调研 编辑:程序博客网 时间:2024/06/05 19:33
2302. Queue Implementation Using a Circular Array
Constraints
Time Limit: 1 secs, Memory Limit: 256 MB , Framework Judge
Description
template <typename T> class Queue {
public:
Queue(); // construct an empty queue
~Queue() // destructor
Queue(const Queue &rhs);
const Queue & operator(const Queue &rhs)
bool empty()const;
bool full()const;
int size()const;
bool push(const T &x);//enqueue
bool pop();//dequeue
const T & front()const;//returns a reference to the front element
private:
//using a static array of size 100.
};
Input
None
Output
None
Hint
Submit your implementation only.
Problem Source
ADTs: Implementations and Applications
// Problem#: 2302// Submission#: 3371367// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/// All Copyright reserved by Informatic Lab of Sun Yat-sen Universitytemplate <typename T> class Queue {public: Queue() { counter = 0; } ~Queue() { counter = 0; } Queue(const Queue &rhs) { counter = rhs.size(); for (int i = 0; i < counter; i++) a[i] = rhs.a[i]; } const Queue & operator=(const Queue &rhs) { counter = rhs.size(); for (int i = 0; i < counter; i++) a[i] = rhs.a[i]; } bool empty() const { return counter == 0; } bool full() const { return counter == 100; } int size() const { return counter; } bool push(const T &x) { if (counter < 100) { a[counter++] = x; return true; } else return false; } bool pop() { if (counter) { for (int i = 0; i < counter - 1; i++) a[i] = a[i + 1]; counter--; return true; } else return false; } const T & front() const { if (counter) return a[0]; }private: T a[105]; int counter;};
0 0
- Sicily 2302. Queue Implementation Using a Circular
- soj 2302. Queue Implementation Using a Circular Array
- Queue implementation: A circular array with one unused location
- Yet another implementation of a lock-free circular array queue
- Yet another implementation of a lock-free circular array queue
- c implementation of a bounded buffer queue using posix threads
- Circular Queue
- Circular Queue
- implement a stack using queue
- implement a queue using stack
- Implement stack using a queue
- Sicily 1888. Circular Sequence
- Sicily 1888. Circular Sequence
- 循环队列(circular queue)
- Thread safe circular queue
- 循环队列(Circular Queue)
- Circular Array implement Queue
- Sicily 2252. List Implementation
- linux下cat命令简略
- Linux-vim
- python中if __name__ == '__main__': 的解析
- NSNotificationCenter的同步和异步
- ext中的一些用法心得
- Sicily 2302. Queue Implementation Using a Circular
- STL之partition和stable_partition
- ListView 的优化及使用
- ios target-action响应方法的不同形式
- cocos2d 中使用jni C++ 调用 Java 方法
- NodeJS+Express模块的跨域访问控制问题
- linux tar.gz zip 解压缩 压缩命令
- 负载均衡服务器nginx安装
- AsyncHttpClient 获取图片和网页数据演示