C# 他与担保/合同相同。没有任何东西可以阻止实现将来的更改。因此,garantuee会将所有3条语句按照其类名的预期进行排序。这不是保证。这是一个实现细节。@mjwills但是基于OP中的文档信息,Garantues为基类上的GetEnumerator使用了一
C# 他与担保/合同相同。没有任何东西可以阻止实现将来的更改。因此,garantuee会将所有3条语句按照其类名的预期进行排序。这不是保证。这是一个实现细节。@mjwills但是基于OP中的文档信息,Garantues为基类上的GetEnumerator使用了一,c#,C#,他与担保/合同相同。没有任何东西可以阻止实现将来的更改。因此,garantuee会将所有3条语句按照其类名的预期进行排序。这不是保证。这是一个实现细节。@mjwills但是基于OP中的文档信息,Garantues为基类上的GetEnumerator使用了一个排序字典,这没有什么不同?您的逻辑没有遵循。合同不保证使用Select语句。所以这并不能保证他们会井然有序。现在,这样做是有道理的——是的。但这与担保/合同不同。没有任何东西可以阻止实现将来的更改。谢谢,在当前实现中,值按键排序,这是我所期望
他与担保/合同相同。没有任何东西可以阻止实现将来的更改。
因此,garantuee会将所有3条语句按照其类名的预期进行排序。
这不是保证。这是一个实现细节。@mjwills但是基于OP中的文档信息,Garantues为基类上的GetEnumerator
使用了一个排序字典,这没有什么不同?您的逻辑没有遵循。合同不保证使用Select
语句。所以这并不能保证他们会井然有序。现在,这样做是有道理的——是的。但这与担保/合同不同。没有任何东西可以阻止实现将来的更改。谢谢,在当前实现中,值按键排序,这是我所期望的。谢谢,在当前实现中,值按键排序,这是我所期望的。
var dict = new Dictionary<long, string>
{
{3, "Three"},
{1, "One"},
{2, "Two"}
}.ToImmutableSortedDictionary();
foreach (var p in dict)
{
System.Console.WriteLine($"{p.Key} - {p.Value}");
}
System.Console.WriteLine();
foreach (var k in dict.Keys)
{
System.Console.WriteLine(k);
}
System.Console.WriteLine();
foreach (var v in dict.Values)
{
System.Console.WriteLine(v);
}
One
Two
Three
/// <summary>
/// Gets the keys.
/// </summary>
internal IEnumerable<TKey> Keys
{
get { return Linq.Enumerable.Select(this, p => p.Key); }
}
/// <summary>
/// Gets the values.
/// </summary>
internal IEnumerable<TValue> Values
{
get { return Linq.Enumerable.Select(this, p => p.Value); }
}
/// <summary>
/// Adds the specified key. Callers are expected to have validated arguments.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="value">The value.</param>
/// <param name="keyComparer">The key comparer.</param>
/// <param name="valueComparer">The value comparer.</param>
/// <param name="overwriteExistingValue">if <c>true</c>, an existing key=value pair will be overwritten with the new one.</param>
/// <param name="replacedExistingValue">Receives a value indicating whether an existing value was replaced.</param>
/// <param name="mutated">Receives a value indicating whether this node tree has mutated because of this operation.</param>
/// <returns>The new AVL tree.</returns>
private Node SetOrAdd(TKey key, TValue value, IComparer<TKey> keyComparer, IEqualityComparer<TValue> valueComparer, bool overwriteExistingValue, out bool replacedExistingValue, out bool mutated)
/// <summary>
/// Removes the specified key. Callers are expected to validate arguments.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="keyComparer">The key comparer.</param>
/// <param name="mutated">Receives a value indicating whether this node tree has mutated because of this operation.</param>
/// <returns>The new AVL tree.</returns>
private Node RemoveRecursive(TKey key, IComparer<TKey> keyComparer, out bool mutated)