⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 base.cpp

📁 仅作参考。 测试环境:WinXP + VC6.0+sp6 Redhat Linux AS 3 + Gcc3.x.x Solaris 10 + Gcc3
💻 CPP
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -