本文整理汇总了C#中INode.Left方法的典型用法代码示例。如果您正苦于以下问题:C# INode.Left方法的具体用法?C# INode.Left怎么用?C# INode.Left使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INode
的用法示例。
在下文中一共展示了INode.Left方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateSize
private static int CalculateSize(INode node)
{
if (node.Left() != null && node.Right() != null && !node.IsLeaf())
{
return CalculateSize(node.Left()) + CalculateSize(node.Right());
;
}
if (node.Left() == null && node.Right() == null && node.IsLeaf())
{
return node.Size();
}
throw new Exception("Badly Constructed INode Tree");
}
示例2: IsEqual
private static bool IsEqual(INode nodeA, INode nodeB)
{
if (nodeA.IsLeaf() ^ nodeB.IsLeaf())
{
throw new Exception("Identical nodes should be at the same height");
}
Assert.IsTrue(nodeA.LeftEdge().Direction == nodeB.LeftEdge().Direction);
Assert.IsTrue(nodeA.RightEdge().Direction == nodeB.RightEdge().Direction);
Assert.IsTrue(nodeA.LeftEdge().Orientation == nodeB.LeftEdge().Orientation);
Assert.IsTrue(nodeA.RightEdge().Orientation == nodeB.RightEdge().Orientation);
if (nodeA.IsLeaf() && nodeB.IsLeaf())
{
return true;
}
return IsEqual(nodeA.Left(), nodeB.Left()) && IsEqual(nodeA.Right(), nodeB.Right());
}
示例3: ValidateEdges
private static bool ValidateEdges(INode node)
{
if (node.IsLeaf())
{
return true;
}
// Get the expected
var actualLeft = node.LeftEdge();
var actualRight = node.RightEdge();
INode left = node;
INode right = node;
while (!left.IsLeaf())
{
left = left.Left();
}
while (!right.IsLeaf())
{
right = right.Right();
}
var expectedLeft = left.LeftEdge();
var expectedRight = right.RightEdge();
Assert.IsTrue(actualLeft == expectedLeft);
Assert.IsTrue(actualRight == expectedRight);
if (actualLeft != expectedLeft || actualRight != expectedRight)
{
return false;
}
// Repeat for node children
return ValidateEdges(node.Left()) && ValidateEdges(node.Right());
}
示例4: IsValid
private static bool IsValid(INode parent)
{
if (parent.Left() == null && parent.Right() == null)
{
return true;
}
else if (parent.Left() == null ^ parent.Right() == null)
{
throw new ArgumentException("Invalid INode - Must have left/right members or both must be null");
}
else
{
bool validLeft = parent.Left().Parent() == parent;
bool validRight = parent.Right().Parent() == parent;
if (validLeft && validRight)
{
return IsValid(parent.Left()) && IsValid(parent.Right());
}
else
{
return false;
}
}
}
示例5: IsMirror
private static bool IsMirror(INode reg, INode rev)
{
if (reg.IsLeaf() ^ rev.IsLeaf())
{
throw new Exception("Mirrored nodes are not at the same height");
}
if (reg.IsLeaf() && rev.IsLeaf())
{
Assert.IsTrue(reg.Size() == rev.Size());
Assert.IsTrue(reg.Leaf().Orientation == Enumeration.Opposite(rev.Leaf().Orientation));
Assert.IsTrue(reg.LeftEdge().Direction == Enumeration.Opposite(rev.RightEdge().Direction));
return true;
}
return IsMirror(reg.Left(), rev.Right()) && IsMirror(reg.Right(), rev.Left());
}
示例6: GetNodeHeight
public static int GetNodeHeight(INode root)
{
// ReSharper disable PossibleNullReferenceException
return root != null ? 0 : Math.Max(GetNodeHeight(root.Left()), GetNodeHeight(root.Right())) + 1;
// ReSharper restore PossibleNullReferenceException
}