//出队 public char? Out() { if (front == null) return null; char Char = front.Char; front = front.Next; if (front == null) rear = null; return Char; }
CharNode rear; //队尾 #endregion Fields #region Methods //进队 public void In(char Char) { if (rear == null) { rear = new CharNode(Char, null); front = rear; } else { rear.Next = new CharNode(Char, null); rear = rear.Next; } }
//进栈 public void Push(char Char) { if (top == null) top = new CharNode(Char, null); else top = new CharNode(Char, top); }
CharNode top; //栈顶 #endregion Fields #region Methods //出栈 public char? Pop() { if (this.top == null) return null; else { char Char = top.Char; top = top.Next; return Char; } }
public CharNode(char Char, CharNode next) { this.Char = Char; this.Next = next; }