Esempio n. 1
0
        public static bool[] ParallelizedArePrimeNumbers(this PrimeCalculator primeCalculator, uint[] numbers)
        {
            var results = RunArePrimeNumbersMethod(
                numbers.PadToMultipleOf(PrimeCalculator.MaxDegreeOfParallelism),
                memory => primeCalculator.ParallelizedArePrimeNumbers(memory));

            // The result might be longer than the input due to padding.
            return(results.CutToLength(numbers.Length));
        }
Esempio n. 2
0
 public static Task <bool> IsPrimeNumberAsync(this PrimeCalculator primeCalculator, uint number)
 {
     return(RunIsPrimeNumber(number, memory => primeCalculator.IsPrimeNumberAsync(memory)));
 }
Esempio n. 3
0
 public static bool[] ArePrimeNumbers(this PrimeCalculator primeCalculator, uint[] numbers)
 {
     return(RunArePrimeNumbersMethod(numbers, memory => primeCalculator.ArePrimeNumbers(memory)));
 }
Esempio n. 4
0
 public static bool IsPrimeNumber(this PrimeCalculator primeCalculator, uint number)
 {
     return(RunIsPrimeNumber(number, memory => Task.Run(() => primeCalculator.IsPrimeNumber(memory))).Result);
 }