/// <summary> /// The MoveNext function traverses the tree in sorted order. /// </summary> /// <returns>True if we found a valid entry, False if we have reached the end</returns> public bool MoveNext() { // For the first entry, find the lowest valued node in the tree if (current == null) { current = theTree.FindMostLeft(theTree.Root); } else { // Can we go right-left? if (current.Right != null) { current = theTree.FindMostLeft(current.Right); } else { // Note the value we have found T CurrentValue = current.Data; // Go up the tree until we find a value larger than the largest we have // already found (or if we reach the root of the tree) while (current != null) { current = current.Parent; if (current != null) { int Compare = theTree.CompareFunction(current.Data, CurrentValue); if (Compare < 0) { continue; } } break; } } } return(current != null); }
// Помогает отсортировать значения public bool MoveNext() { // Первая запись - всегда самое малое значение if (current == null) { current = theTree.FindMostLeft(theTree.Root); } else { // Куда поворачивать? if (current.Right != null) { current = theTree.FindMostLeft(current.Right); } else { // Нашли значения T CurrentValue = current.Data; // Поднимаемся по дереву - от большего к большему значению while (current != null) { current = current.Parent; if (current != null) { int Compare = theTree.CompareFunction(current.Data, CurrentValue); if (Compare < 0) { continue; } } break; } } } return(current != null); }