本文整理汇总了C#中ElaValue.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# ElaValue.CompareTo方法的具体用法?C# ElaValue.CompareTo怎么用?C# ElaValue.CompareTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElaValue
的用法示例。
在下文中一共展示了ElaValue.CompareTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
internal virtual AvlTree Add(ElaValue key, ElaValue value)
{
var result = default(AvlTree);
if (key.CompareTo(Key) > 0)
result = new AvlTree(Key, Value, Left, Right.Add(key, value));
else
result = new AvlTree(Key, Value, Left.Add(key, value), Right);
return MakeBalanced(result);
}
示例2: Remove
internal virtual AvlTree Remove(ElaValue key)
{
var result = default(AvlTree);
var compare = key.CompareTo(Key);
if (compare == 0)
{
if (Right.IsEmpty && Left.IsEmpty)
result = Empty;
else if (Right.IsEmpty && !Left.IsEmpty)
result = Left;
else if (!Right.IsEmpty && Left.IsEmpty)
result = Right;
else
{
var successor = Right;
while (!successor.Left.IsEmpty)
successor = successor.Left;
result = new AvlTree(successor.Key, successor.Value, Left, Right.Remove(successor.Key));
}
}
else if (compare < 0)
result = new AvlTree(Key, Value, Left.Remove(key), Right);
else
result = new AvlTree(Key, Value, Left, Right.Remove(key));
return MakeBalanced(result);
}
示例3: Search
internal virtual AvlTree Search(ElaValue key)
{
var compare = key.CompareTo(Key);
if (compare == 0)
return this;
else if (compare > 0)
return Right.Search(key);
else
return Left.Search(key);
}