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

📄 lxlstack.cpp

📁 vc编写的数据结构
💻 CPP
字号:
// lxlstack.cpp: implementation of the lxlstack class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "lxlstack.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

lxlstack::lxlstack(int sz=defaultlistsize)
{
	top=NULL;size=0;

}

lxlstack::~lxlstack()
{
	clear();

}

void lxlstack::clear()
{
	while(top!=NULL){
		lxlink* temp=top;
		top=top->next;
		delete temp;
	}
	size=0;
}

bool lxlstack::push(const int &item)
{
	top=new lxlink(item,top);
	size++;
	return 0;

}

bool lxlstack::pop(int &it)
{
	if(size==0)return false;
	it=top->element;
	lxlink* ltemp=top->next;
	delete top;
	top=ltemp;
	size--;
	return true;

}

bool lxlstack::topvalue(int &it) const
{
	if(size==0) return false;
	it=top->element;
	return true;

}

int lxlstack::length() const
{
	return size;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -