コード例 #1
0
        public static T min <T, V>(this IEnumerable <T> e, Func <T, V> transformFn)
        {
            var mo = MathOperations.Get <V>();

            V minv = mo.max;
            T r    = default(T);

            foreach (var i in e)
            {
                V cv = transformFn(i);
                if (mo.lt(cv, minv))
                {
                    minv = cv;
                    r    = i;
                }
            }

            return(r);
        }
コード例 #2
0
        public static T max <T, V>(this IEnumerable <T> e, Func <T, V> transformFn)
        {
            var mo = MathOperations.Get <V>();

            V maxv = mo.min;
            T r    = default(T);

            foreach (var i in e)
            {
                V v = transformFn(i);
                if (mo.gt(v, maxv))
                {
                    maxv = v;
                    r    = i;
                }
            }

            return(r);
        }