Example #1
0
        /// <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);
        }
Example #2
0
        /// <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));
        }
Example #3
0
 public DictionaryEnumerator([NotNull] SortedList <TKey, TValue> host)
     : this(host, EnumeratorMode.ENTRY_MODE)
 {
 }
Example #4
0
 public void Dispose()
 {
     host = null;
 }
Example #5
0
 public Enumerator(SortedList <TKey, TValue> host)
 {
     this.host = host;
 }
Example #6
0
 internal ValueEnumerator([NotNull] SortedList <TKey, TValue> l)
 {
     this.l = l;
     idx    = NOT_STARTED;
     ver    = l.modificationCount;
 }