Exercise 3.3 E7
来源:互联网 发布:mac 计时钟表 编辑:程序博客网 时间:2024/04/30 08:15
E7 Rewrite the methods for queue processing from the text ,using a flag to indicate a full queue instead of keeping a count of the entries in the queue
注:重新编写课本中队列处理的方法,使用一个标志而不是保持队列中元素个数的计数来指示满队列。
const int maxqueue=10;
class Queue{
public:
Queue();
bool empty() const;
Error_code serve();
Error_code append (const Queue_entry&item);
Error_code retrieve (Queue_entry&item)const;
protected;
int front ,rear;
Queue_entry entry[maxqueue];
bool is_empty;
};
{
rear=-1;
front=0;
is_empty=true;
}
bool Queue::empty()const
{
return is_empty;
}
Error_code Queue::append(const Queue_entry&item)
{
if{empty()}
return underflow;
if{rear==front}is_empty=true;
front=((front+1)==maxqueue)?0:(front+1)
return success;
}
Error_code Queue::retrieve(Queue_entry&item)const;
{
if{empty()}return underflow;
item =entry[front];
return success;
}
- Exercise 3.3 E7 解答
- Exercise 3.3 E7 解答
- Exercise 3.3E7
- Exercise 3.3 E7
- 3.3 E7
- 3.3E7
- 3.3E7
- 3.3 E7
- 3.3E7
- 3.3 E7
- 3.3 E7
- Exercises 3.3 E7
- Exercises 3.3 E7
- Exercises 3.3 E7
- Exercises 3.3 E7
- Exercises 3.3 E7
- Exercises 3.3 E7
- Exercises 3.3 E7
- 介绍一个C++奇巧淫技
- HBase性能优化方法总结
- 股评 2013-09-04
- 七个高效的文本编辑习惯(以Vim为例)
- 数据库删除操作(drop, delete,truncate)
- Exercise 3.3 E7
- Windows 反调试参考翻译1
- C语言-字符串的定义与初始化
- xml 树状显示
- Windows 反调试参考翻译2
- poj 1289 The Cat in the Hat
- 字符串补充-字符串的\0
- 需要判断字符串中是否含有双引号
- listView 动态设置高亮