提交 c6454b52 编写于 作者: C Cyrus Najmabadi

PR feedback.

上级 ac100a62
......@@ -153,44 +153,6 @@ public void TestOverlappingStart()
}
}
[Fact]
public void TestRightRotation()
{
var nodes = new[]
{
Tuple.Create(8, 1, "a"),
Tuple.Create(10, 1, "b"),
Tuple.Create(4, 1, "c"),
Tuple.Create(6, 1, "d"),
Tuple.Create(0, 1, "e"),
Tuple.Create(2, 1, "f")
};
foreach (var tree in CreateTrees(nodes))
{
Assert.True(tree.GetPreOrder().Select(t => t.Item3).SequenceEqual(
List("c", "e", "f", "a", "d", "b")));
}
}
[Fact]
public void InnerLeftOuterRightRotation()
{
var nodes = new[]
{
Tuple.Create(8, 1, "a"),
Tuple.Create(10, 1, "b"),
Tuple.Create(2, 1, "c"),
Tuple.Create(0, 1, "e"),
Tuple.Create(4, 1, "d"),
Tuple.Create(6, 1, "f")
};
foreach (var tree in CreateTrees(nodes))
{
Assert.True(tree.GetPreOrder().Select(t => t.Item3).SequenceEqual(
List("d", "c", "e", "a", "f", "b")));
}
}
[Fact]
public void TestOverlappingEnd()
{
......
......@@ -17,7 +17,6 @@ internal partial class IntervalTree<T> : IEnumerable<T>
public static readonly IntervalTree<T> Empty = new IntervalTree<T>();
protected Node root;
private readonly int count;
private delegate bool TestInterval(T value, int start, int length, IIntervalIntrospector<T> introspector);
private static readonly TestInterval s_intersectsWithTest = IntersectsWith;
......@@ -37,13 +36,10 @@ public IntervalTree()
public IntervalTree(IIntervalIntrospector<T> introspector, IEnumerable<T> values)
: this(root: null)
{
var count = 0;
foreach (var value in values)
{
root = Insert(root, new Node(introspector, value), introspector, inPlace: true);
count++;
}
this.count = count;
}
protected static bool Contains(T value, int start, int length, IIntervalIntrospector<T> introspector)
......@@ -339,29 +335,6 @@ public IEnumerator<T> GetEnumerator()
}
}
// For testing purposes only. Allows a test to verify the actual AVL structure of the tree.
internal IEnumerable<T> GetPreOrder()
{
if (root == null)
{
yield break;
}
// The bool indicates if this is the first time we are seeing the node.
var candidates = new Stack<Node>();
candidates.Push(root);
while (candidates.Count != 0)
{
var currentNode = candidates.Pop();
if (currentNode != null)
{
candidates.Push(currentNode.Right);
candidates.Push(currentNode.Left);
yield return currentNode.Value;
}
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册