public void TestCount()
        {
            NullableLargeArray <int> array = new NullableLargeArray <int>();

            for (int x = 0; x < 100000; x++)
            {
                array.AddValue(x);
            }

            for (int x = 0; x < 100000; x += 2)
            {
                if (array[x] != x)
                {
                    throw new Exception();
                }
                array.SetNull(x);
            }

            if (array.Capacity != 100000 + (1024 - (100000 & 1023)))
            {
                throw new Exception();
            }
            if (array.CountUsed != 50000)
            {
                throw new Exception();
            }
            if (array.CountFree != array.Capacity - 50000)
            {
                throw new Exception();
            }


            int i;

            for (int x = 1; x < 100000; x += 2)
            {
                if (!array.TryGetValue(x, out i))
                {
                    throw new Exception();
                }
                if (i != x)
                {
                    throw new Exception();
                }
            }

            for (int x = 0; x < 100000; x += 2)
            {
                if (array.TryGetValue(x, out i))
                {
                    throw new Exception();
                }
            }

            if (array.Count() != 50000)
            {
                throw new Exception();
            }

            i = 1;
            foreach (int item in array)
            {
                if (item != i)
                {
                    throw new Exception();
                }
                i += 2;
            }

            if (array.Select(x => x).Count() != 50000)
            {
                throw new Exception();
            }


            for (int x = 1; x < 100000; x += 2)
            {
                array.OverwriteValue(x, -1);
            }

            for (int x = 1; x < 100000; x += 2)
            {
                if (array[x] != -1)
                {
                    throw new Exception();
                }
            }
        }
        public void TestCount()
        {
            NullableLargeArray<int> array = new NullableLargeArray<int>();

            for (int x = 0; x < 100000; x++)
            {
                array.AddValue(x);
            }

            for (int x = 0; x < 100000; x += 2)
            {
                if (array[x] != x)
                    throw new Exception();
                array.SetNull(x);
            }

            if (array.Capacity != 100000 + (1024 - (100000 & 1023)))
                throw new Exception();
            if (array.CountUsed != 50000)
                throw new Exception();
            if (array.CountFree != array.Capacity - 50000)
                throw new Exception();


            int i;
            for (int x = 1; x < 100000; x += 2)
            {
                if (!array.TryGetValue(x, out i))
                    throw new Exception();
                if (i != x)
                    throw new Exception();
            }

            for (int x = 0; x < 100000; x += 2)
            {
                if (array.TryGetValue(x, out i))
                    throw new Exception();
            }

            if (array.Count() != 50000)
                throw new Exception();

            i = 1;
            foreach (var item in array)
            {
                if (item != i)
                    throw new Exception();
                i += 2;
            }

            if (array.Select(x => x).Count() != 50000)
                throw new Exception();


            for (int x = 1; x < 100000; x += 2)
            {
                array.OverwriteValue(x, -1);
            }

            for (int x = 1; x < 100000; x += 2)
            {
                if (array[x] != -1)
                    throw new Exception();
            }

        }