/// <summary> /// Compares two collection, element by elements. /// </summary> /// <param name="first">The collection to compare from.</param> /// <param name="second">The colllection to compare to.</param> /// <returns>True if lists are identical (but not necessarily in the same order). False otherwise.</returns> /// <remarks>Concrete SortedList is favored over interface to avoid enumerator object allocation.</remarks> public static bool Compare <TKey, TValue>(Collections.SortedList <TKey, TValue> first, Collections.SortedList <TKey, TValue> second) { if (ReferenceEquals(first, second)) { return(true); } if (ReferenceEquals(first, null) || ReferenceEquals(second, null)) { return(false); } if (first.Count != second.Count) { return(false); } var comparer = EqualityComparer <TValue> .Default; foreach (var keyValue in first) { TValue secondValue; if (!second.TryGetValue(keyValue.Key, out secondValue)) { return(false); } if (!comparer.Equals(keyValue.Value, secondValue)) { return(false); } } return(true); }
/// <summary> /// Compares two collection, element by elements. /// </summary> /// <param name="first">The collection to compare from.</param> /// <param name="second">The colllection to compare to.</param> /// <returns>True if lists are identical (but not necessarily in the same order). False otherwise.</returns> /// <remarks>Concrete SortedList is favored over interface to avoid enumerator object allocation.</remarks> public static bool Compare <TKey, TValue>(Collections.SortedList <TKey, TValue> first, Collections.SortedList <TKey, TValue> second) { if (ReferenceEquals(first, second)) { return(true); } if (ReferenceEquals(first, null) || ReferenceEquals(second, null)) { return(false); } return(first.Equals(second)); }
public DictionaryEnumerator([NotNull] SortedList <TKey, TValue> host) : this(host, EnumeratorMode.ENTRY_MODE) { }
public void Dispose() { host = null; }
public Enumerator(SortedList <TKey, TValue> host) { this.host = host; }
internal ValueEnumerator([NotNull] SortedList <TKey, TValue> l) { this.l = l; idx = NOT_STARTED; ver = l.modificationCount; }