C # data structure (stack)

xiaoxiao2021-03-06  43

The smoke is not there, others are harmful, but they are essential to me, huh, huh. . I wrote a smoke program, I'm okay, then I will complete the stack. In fact, the stack and linear table have no big difference, the stack is actually a special linear table, using Push pressing data, The POP pop-up data is used, which is as simple as the principle of advanced. The List class has been written in front, where we can call it. code show as below:

Using system;

Namespace list {/// Stack class public class cstack {// Call Link Laboch CLIST M_LIST;

Public cstack () {// Constructor m_list = new clist ();

/// Pressing the Push PUBLIC VOID PUSH (INT PUSHVALUE) {// Parameters: int PushValue Press the stack of data m_list.append (pushvalue);

/// Pop up the stack data, if it is empty, get the maximum value of 2147483647 is int, PUBLIC INT POP () {// Function: Pop-up stack data

INT POPVALUE; if (! isnullstack ()) {// is not empty // to the top MOVETOP (); // get the popcast data PopValue = getCurrentValue (); // Delete delete (); return popValue;} / / Empty time is the maximum value of the INT RETURN 2147483647;

/// Deconstimate whether the stack is incaps PUBLIC BOOL INULLSTACK () {if (m_list.isnull ()) Return True; Return False;}

/// The number of stacks public int stocklistcount {get {return m_list.listcount;}}

/// Move to the bottom of the stack public void movebottom () {m_list.movefrist ();

/// Move to the stack TOP public void movetop () {m_list.movelast ();

/ / / Move PUBLIC VOID MOVEUP () {m_list.movenext ();

/ / / Move PUBLIC VOID MOVEDOWN () {m_list.moveprevious ();

/// get the current value public int getCurrentValue () {return m_list.getcurrentValue ();}

/// Remove the current node public void delete () {m_list.delete ();}

/// Clear Stack Public Void Clear () {m_list.clear ();}}}

转载请注明原文地址:https://www.9cbs.com/read-55055.html

New Post(0)