public static Node GetNextNode(Node startingNode, int searchOffset) { if (searchOffset == 0) { return(startingNode); } if (searchOffset > 0) { ForwardNodeEnumerator iterator = new ForwardNodeEnumerator(startingNode, true); while (searchOffset-- >= 0 && iterator.MoveNext()) { ; } return(iterator.Current); } if (searchOffset < 0) { ReverseNodeEnumerator iterator = new ReverseNodeEnumerator(startingNode, true); while (searchOffset++ <= 0 && iterator.MoveNext()) { ; } return(iterator.Current); } return(null); }
public static IEnumerable ReverseNodeIterator(Node firstNode, Node lastNode, bool mustBeVisible) { bool m_done = false; ReverseNodeEnumerator iterator = new ReverseNodeEnumerator(firstNode, mustBeVisible); while (iterator.MoveNext()) { if (m_done) break; if (iterator.Current == lastNode) m_done = true; yield return iterator.Current; } }