Esempio n. 1
0
        public static void BinarySearch()
        {
            var distributedArray = new BigArray <int>();

            for (int i = 0; i < 512; i += 2)
            {
                distributedArray.Add(i);
            }

            Assert.AreEqual(distributedArray.BinarySearch(128), 64);
            Assert.AreEqual(~distributedArray.BinarySearch(0, 64, 130, Comparer <int> .Default), 64);
            Assert.AreEqual(~distributedArray.BinarySearch(-100), 0);
            Assert.AreEqual(~distributedArray.BinarySearch(1), 1);

            var emptyArray = new BigArray <int>();

            Assert.AreEqual(~emptyArray.BinarySearch(1), 0);
        }