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); }
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); }
/// <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); }
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); }