public void AddNode(LinkedNode node) { if (this.CurrentNode != null) { this.CurrentNode.NextNode = node; this.CurrentNode = node; } }
static void Main(string[] args) { LinkedList list = InitList(); LinkedNode node = list.FindLoopNode(); //comment Console.Read(); }
public LinkedNode FindLoopNode() { List <LinkedNode> checkedNodes = new List <LinkedNode>(); LinkedNode node = this.StartNode; while (!checkedNodes.Contains(node)) { checkedNodes.Add(node); Console.WriteLine("check node:" + node.Data); node = node.NextNode; } if (checkedNodes.Count > 1) { Console.WriteLine("loop node is:" + node.Data); } return(node); }
public LinkedList(LinkedNode startNode) { this.StartNode = startNode; this.CurrentNode = startNode; }