public void Add(T inNode) { vertices.Add(new CycleNode <T>(inNode)); contents.Add(inNode); CurrentNode = vertices[0]; if (vertices.Count == 1) { vertices[0].Next = vertices[0]; } else { vertices[vertices.Count - 2].Next = vertices[vertices.Count - 1]; vertices[vertices.Count - 1].Next = vertices[0]; } }
public T Next() { CurrentNode = CurrentNode.Next; return(CurrentNode.Contents); }
public CycleNode(T contents, CycleNode <T> next) { Contents = contents; Next = next; }