struct QueueNode { int Data; struct QueueNode* next; }; struct QueueLink { struct QueueNode* front; struct QueueNode* rear; }; /** * @brief 删除队列的队头结点 * @param[in] queue 待删除元素队列 * @param[out] e 删除结点的值 * @return 返回函数执行结果 * - 0 表示操作成功 * - -1 表示操作失败 * @author wlq_729@163.com * http://blog.csdn.net/rabbit729 * @version 1.0 * @date 2009-03-10 */ int DeQueue(QueueLink* queue, int& e) { if (NULL == queue) { cout<<"point is null!"<<endl; return -1; } if(queue->front == queue->rear) { cout<<"queue is null!"<<endl; return -1; } QueueNode* p = queue->front->next; e = p->Data; queue->front->next = p->next; if (queue->rear == p) { queue->rear = queue->front; } delete p; p = NULL; return 0; }
posted on 2009-03-10 12:25 张云临 阅读(400) 评论(0) 编辑 收藏 举报