public static void AddNewBlockAndInsertNewBlock()
        {
            var blockCollection = new BlockCollection <int>();

            //Add
            blockCollection.AddNewBlock();
            Assert.AreEqual(blockCollection.Count, 1);
            //Add
            blockCollection.AddNewBlock();
            Assert.AreEqual(blockCollection.Count, 2);
            //Insert
            blockCollection.InsertNewBlock(1);
            Assert.AreEqual(blockCollection.Count, 3);
        }
示例#2
0
        public static void AddNewBlockAndInsertNewBlock()
        {
            var blockCollection = new BlockCollection<int>();

            //Add
            blockCollection.AddNewBlock();
            Assert.AreEqual(blockCollection.Count, 1);
            //Add
            blockCollection.AddNewBlock();
            Assert.AreEqual(blockCollection.Count, 2);
            //Insert
            blockCollection.InsertNewBlock(1);
            Assert.AreEqual(blockCollection.Count, 3);
        }
示例#3
0
        /// <summary>
        /// Add an object to the end of last block of the <see cref="BigArray{T}"/>.
        /// </summary>
        public void Add(T value)
        {
            int indexOfBlock = _blockCollection.Count - 1;

            if (_blockCollection.Count == 0 || _blockCollection[indexOfBlock].Count >= _balancer.GetMaxBlockSize(indexOfBlock))
            {
                indexOfBlock++;
                _blockCollection.AddNewBlock();
            }

            _blockCollection[indexOfBlock].Add(value);
            _arrayMap.DataChanged(indexOfBlock);

            Count++;
        }
        public static void TryToDivideBlock()
        {
            var blockCollection = new BlockCollection <int>();

            blockCollection.AddNewBlock();

            //Fill block 2 times
            for (int i = 0; i < MaxBlockSize * 2; i++)
            {
                blockCollection[0].Add(i);
            }

            Assert.AreEqual(blockCollection.Count, 1);

            blockCollection.TryToDivideBlock(0);

            Assert.AreEqual(blockCollection.Count, 2 * MaxBlockSize / DefaultBlockSize);
        }
示例#5
0
        public static void TryToDivideBlock()
        {
            var blockCollection = new BlockCollection<int>();
            blockCollection.AddNewBlock();

            //Fill block 2 times
            for (int i = 0; i < MaxBlockSize * 2; i++)
            {
                blockCollection[0].Add(i);
            }

            Assert.AreEqual(blockCollection.Count, 1);

            blockCollection.TryToDivideBlock(0);

            Assert.AreEqual(blockCollection.Count, 2 * MaxBlockSize / DefaultBlockSize);
        }