Exemple #1
0
    public static bool SequenceEquals <T>(
        this T[]?left,
        T[]?right,
        InFunc <T, T, bool> comparer)
    {
        InFunc <T, T, bool> localComparer = Requires.NotNull(comparer);

        if (left == null)
        {
            return(right == null);
        }

        if (right == null)
        {
            return(false);
        }

        if (left.Length != right.Length)
        {
            return(false);
        }

        for (var i = 0; i < left.Length; i++)
        {
            if (!localComparer(
                    in left[i],
                    in right[i]))
            {
                return(false);
            }
        }

        return(true);
    }
Exemple #2
0
        public double ff(double a, double b, InFunc Func, double y, double eps)
        {
            double x;

            x = 1;
            return(x);
        }
Exemple #3
0
 public Mapper(InFunc <TFrom, TTo> to, InFunc <TTo, TFrom> from, Serializer <TTo> serializer = null)
 {
     To         = to;
     From       = from;
     Serializer = serializer;
 }
Exemple #4
0
 private static void InFunc_Method <T, R>(InFunc <T, R> inFunc)
 {
 }
    /// <summary>
    ///     Compares two arrays to one another sequentially.
    /// </summary>
    /// <typeparam name="T">The type of the item in the array.</typeparam>
    /// <param name="left">The left operand array.</param>
    /// <param name="right">The right operand array.</param>
    /// <param name="comparer">The comparer to use when equating items.</param>
    /// <returns>The result of the comparison.</returns>
    public static int SequenceCompare <T>(
        this T[]?left,
        T[]?right,
        InFunc <T, T, int> comparer)
    {
        InFunc <T, T, int> localComparer = Requires.NotNull(comparer);

        if (left == null)
        {
            // Left is null, we return based on whether or not right is null as well
            return(right == null ? 0 : int.MinValue);
        }

        if (right == null)
        {
            // Right is null, but not left
            return(int.MaxValue);
        }

        var i = 0;

        while (true)
        {
            var b1 = i < left.Length;
            var b2 = i < right.Length;

            if (!b1 && !b2)
            {
                // We have reached the end
                return(0);
            }

            T?c1 = b1 ? left[i] : default;
            T?c2 = b2 ? right[i] : default;

            if (c1 == null)
            {
                if (c2 == null)
                {
                    // Both are null, go to next
                    i++;

                    continue;
                }

                // Left is null, right is not
                return(int.MinValue);
            }

            if (c2 == null)
            {
                // Right is null, left is not
                return(int.MaxValue);
            }

            var cr = localComparer(
                in c1,
                in c2);
            if (cr != 0)
            {
                // We have reached the first difference
                return(cr);
            }

            // No difference at this level, let's proceed
            i++;
        }
    }
Exemple #6
0
 public Function(InFunc <T, Context, Result <Runner[]> > schedule)
 {
     _schedule = schedule;
 }
Exemple #7
0
 public static Scheduler <T> From <T>(InFunc <T, Result <Runner[]> > schedule) where T : struct, INode => From((in T data, in Context _) => schedule(data));
Exemple #8
0
 public static Node Inject <T1, T2>(InFunc <T1, T2, Node> provide) => throw null;