stack.h

来自「this is a lp0 compilator new」· C头文件 代码 · 共 96 行

H
96
字号
//// *********************************************************************// *// *	Author 		: Gerald Carter// *	Filename	: stack.h// *	Date		: 4/22/96// *	Project		: Compx Timing Tool// *// *	Description // *	------------// *	This is a stack implementation for the generation of the // *	Maple Expression Tree.// *// *    -------------------------// *    Modifications// *    -------------------------// *	961219  cartegw@humsci.auburn.edu	Gerald Carter// *		Moved the nodeLink class to s separate header file// *		for use by other ADT templates// *// **********************************************************************//// g++ template pragma#pragma interface// INCLUDE FILES#include <iostream.h>      // I/O streams (cin, cout, cerr)#include "logic.h"         // boolean typedef and associated macros#include "link.h"	   // nodeLink class#ifndef _STACK_H#define _STACK_H// ####################################################################// ## class stackNode// ##// macros for indexing pointers in link class#define NEXT      0#define PREVIOUS  1template <class T, int size>class stackNode : public nodeLink<size> {   private :      T       data;   public :      // CONSTRUCTORS      stackNode (void) {         SetLink(NEXT, 0);          SetLink(PREVIOUS, 0);       }      stackNode (const T& item, nodeLink<2>* pt1=0, nodeLink<2>* pt2=0) {         data = item;          SetLink ( NEXT, pt1 );          SetLink ( PREVIOUS, pt2 );       }      // GENERAL METHODS      void SetData (const T& item) { data = item; }       T GetData (void) { return data; } };     // end of class node// ####################################################################// ## class stack// ##template <class T>class stack {   private :      stackNode<T, 2>    *top;      int                 node_count;   public :      // CONSTRUCTORS      stack (void)	 { top = 0; node_count = 0; }      stack (const stack&);            // DESTRUCTOR      ~stack (void);      // GENERAL METHODS      T Pop (void);         		// Pop top object from stack      boolean Push (const T&);      	// Push object onto top of stack      T TopofStack (void) { return top->GetData(); }       boolean IsEmpty (void) const { return ( node_count == 0 ); }       void Dump (void);     		// empty stack      void Print (ostream&);    	// print contents of stack}; // end of stack class#endif//********** end of stack.h ***********************************************//*************************************************************************

⌨️ 快捷键说明

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