Example #1
0
        /// <summary>
        /// (Implementation) Constructs a sequential collection of the specified type by sorting the elements of the current collection using the specified comparer.
        /// </summary>
        /// <typeparam name="TRList"></typeparam>
        /// <param name="bFactory"></param>
        /// <param name="comparer"></param>
        /// <returns></returns>
        protected virtual TRList _OrderBy <TRList>(TRList bFactory, IComparer <TElem> comparer)
            where TRList : IBuilderFactory <ISequentialBuilder <TElem, TRList> >
        {
            bFactory.CheckNotNull("bFactory");
            comparer.CheckNotNull("comparer");
            var arr = ToArray();

            Array.Sort(arr, comparer);
            using (var builder = bFactory.EmptyBuilder)
            {
                Array.ForEach(arr, x => builder.Add(x));
                return(builder.Produce());
            }
        }
Example #2
0
 /// <summary>
 /// Determines whether this map is equal to a sequence of key-value pairs. Maps are equal if they contain the same keys, and if the values associated with them are also equal.
 /// </summary>
 /// <param name="other">A sequence of key-value pairs. This operation is much faster if it's a map compatible with this one.</param>
 /// <param name="comparer">A comparer for determining the equality of values.</param>
 /// <returns></returns>
 public bool MapEquals(IEnumerable <KeyValuePair <TKey, TValue> > other, IComparer <TValue> comparer)
 {
     comparer.CheckNotNull("comparer");
     return(MapEquals(other, (a, b) => comparer.Compare(a, b) == 0));
 }