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

📄 stack.cc

📁 linux下的一个分组遗传算法
💻 CC
字号:
//// stack.cc - general stack.//// author: J.I.v.Hemert// last updated: 29-09-1997//// This file contains the class StackC. It's a general push and pop// stack. The data it stores is defined by the typedef StackT.//#include "stack.h"StackC::StackC ()// New stack, new top.{	top = NULL;} // StackC ()void StackC::Push (StackT data)// Throw something on the top of the stack.{	InternalStackP tmp;	tmp = (InternalStackP) malloc (sizeof (InternalStackT));	tmp->data = data;	tmp->next = top;	top = tmp;} // Push ()StackT StackC::Pop ()// Pop the stack and return what was on the top.{	InternalStackP tmp;	StackT data;	if (! Empty ())	{		tmp = top;		top = top->next;		data = tmp->data;		free (tmp);		return (data);	}	else		return (0);} // Pop ()StackT StackC::Look ()// Take a peek at the top of the stack, no changes are made.{	if (! Empty ())		return (top->data);	else		return (0);} // Show ()bool StackC::Empty ()// Check if the stack is empty.{	if (top == NULL)		return (true);	else		return (false);} // Empty ()StackC::~StackC ()// Stack is thrown away, neatly dispose all items on it.{	while (! Empty ())		Pop ();} // ~StackC ()// eof stack.cc

⌨️ 快捷键说明

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