/// <summary> /// 弹出堆栈 /// </summary> /// <param name="newValue"></param> public T Pop() { T ret = default(T); if (count != 0) { ret = _top._value; if (_top == _bottom) { _count--; return(ret); } _top.bottom.top = _top; //下一节点 _top = _top.bottom; //当前节点 _count--; } return(ret); }
/// <summary> /// 压入堆栈 /// </summary> /// <param name="newValue"></param> public void Push(T sender) { CCStackNode <T> newNode = new CCStackNode <T>(sender); if (count == 0) { _top = newNode; _bottom = newNode; _bottom.top = newNode; } else { _top.top = newNode; //当前节点值 newNode.bottom = _top; //下一节点 _top = newNode; //当前节点 } _count++; return; }