// ------------------------------------------------------------------------------------------- /// <summary> /// Resets the traveling stack. /// </summary> public void ResetStack() { if (TravelingStack != null) { TravelingStack.Clear(); } }
// ------------------------------------------------------------------------------------------- /// <summary> /// Adds the currently pointed node into the traveling stack. /// </summary> public void PushNode() { if (TravelingStack == null) { TravelingStack = new Stack <SimpleNode <TData> >(); // CAUTION: Could not work inside an iterator. } TravelingStack.Push(this.CurrentNode); }
// ------------------------------------------------------------------------------------------- /// <summary> /// Extracts the last stored node from the traveling stack making it the current. Returns whether the operation was successful. /// </summary> public bool PopNode() { if (TravelingStack == null || TravelingStack.Count < 1) { return(false); } this.CurrentNode = TravelingStack.Pop(); return(true); }