base.cpp
来自「仅作参考。 测试环境:WinXP + VC6.0+sp6 Redhat L」· C++ 代码 · 共 106 行
CPP
106 行
#include "../include/base.h"Stack::Stack(){ m_stack.top = NULL; m_list = NULL;}Stack::~Stack(){ list_t* plist = pop(&m_stack); while(plist != NULL) { free(plist); plist = NULL; plist = pop(&m_stack); } plist = m_list; while(plist != NULL) { m_list = plist->prev; plist->prev = NULL; plist->next = NULL; free(plist); plist = m_list; }}void Stack::Push(char* value){ push(&m_stack,value);}char* Stack::Pop(){ char* retValue = NULL; list_t* plist = pop(&m_stack); if(plist != NULL) { retValue = plist->item; } if(m_list != NULL) { m_list->next = plist; if(plist != NULL) { plist->prev = m_list; plist->next = NULL; } } if(plist != NULL) { m_list = plist; } return retValue;}Queue::Queue(){ m_queue.front = NULL; m_queue.rear = NULL; m_list = NULL;}Queue::~Queue(){ list_t* plist = dequeue(&m_queue); while(plist != NULL) { free(plist); plist = NULL; plist = dequeue(&m_queue); } plist = m_list; while(plist != NULL) { m_list = plist->prev; plist->prev = NULL; plist->next = NULL; free(plist); plist = m_list; }}void Queue::Enqueue(char* value){ enqueue(&m_queue,value);}char* Queue::Dequeue(){ char* retValue = NULL; list_t* plist = dequeue(&m_queue); if(plist != NULL) { retValue = plist->item; } if(m_list != NULL) { m_list->next = plist; if(plist != NULL) { plist->prev = m_list; plist->next = NULL; } } if(plist != NULL) { m_list = plist; } return retValue;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?