/// <summary>
        /// Creates dictionary instance from KeyValuePair entries.
        /// </summary>
        /// <typeparam name="T">Type of key</typeparam>
        /// <typeparam name="TV">Type of value</typeparam>
        /// <param name="entries">entries</param>
        /// <returns>dictionary</returns>
        public static IDictionary <T, TV> CreateFromEntries <T, TV>(params KeyValuePair <T, TV>[] entries)
        {
            var dictionary = new Dictionary <T, TV>(entries.Length);

            dictionary.PutAll(entries);
            return(ComparableDictionary <T, TV> .Of(dictionary));
        }
        /// <summary>
        /// Maps collection items to number of occurrences.
        /// </summary>
        /// <typeparam name="T">Type of collection item</typeparam>
        /// <param name="source">this</param>
        /// <returns>Dictionary (item, itemCount)</returns>
        public static IDictionary <T, int> DistinctElementCount <T>(this IEnumerable <T> source)
        {
            Preconditions.IsNotNull(source, () => new ArgumentNullException("source"));
            var result = new Dictionary <T, int>();

            foreach (var element in source)
            {
                if (result.ContainsKey(element))
                {
                    result[element] = result[element] + 1;
                }
                else
                {
                    result[element] = 1;
                }
            }
            return(ComparableDictionary <T, int> .Of(result));
        }
 /// <summary>
 /// Converts dictionary into comparable dictionary with equals/hashCode/toString implementations.
 /// </summary>
 /// <typeparam name="TKey">Type of dictionary key</typeparam>
 /// <typeparam name="TValue">Type of dictionary value</typeparam>
 /// <param name="source">this</param>
 /// <returns>Comparable dictionary</returns>
 public static IDictionary <TKey, TValue> ToComparable <TKey, TValue>(this IDictionary <TKey, TValue> source)
 {
     Preconditions.IsNotNull(source, () => new ArgumentNullException("source"));
     return(ComparableDictionary <TKey, TValue> .Of(source));
 }