FindFreeSpan() public method

public FindFreeSpan ( ulong length ) : ulong
length ulong
return ulong
Beispiel #1
0
 public void Mixed()
 {
     BitArray array = new BitArray(new Boolean[] { true, true, false, false, true, false, false, false, true, true, false });
     Defrag.IFreeSpace tree = new Defrag.FreeSpaceTree(array);
     Assert.AreEqual(6, tree.TotalFreeSpace());
     Assert.AreEqual(3, tree.LargestFreeSpan());
     Assert.AreEqual(2, tree.FindFreeSpan(1));
     Assert.AreEqual(2, tree.FindFreeSpan(2));
     Assert.AreEqual(5, tree.FindFreeSpan(3));
     Assert.AreEqual(UInt64.MaxValue, tree.FindFreeSpan(4));
 }
Beispiel #2
0
        public void AllocateFromEmpty()
        {
            BitArray array = new BitArray(12, false);
            Defrag.IFreeSpace tree = new Defrag.FreeSpaceTree(array);
            Assert.AreEqual(12, tree.TotalFreeSpace());
            Assert.AreEqual(12, tree.LargestFreeSpan());
            tree.Allocate(2, 1);
            Assert.AreEqual(11, tree.TotalFreeSpace());
            Assert.AreEqual(9, tree.LargestFreeSpan());
            Assert.AreEqual(0, tree.FindFreeSpan(1));
            Assert.AreEqual(0, tree.FindFreeSpan(2));
            Assert.AreEqual(3, tree.FindFreeSpan(3));
            Assert.AreEqual(3, tree.FindFreeSpan(4));
            Assert.AreEqual(3, tree.FindFreeSpan(5));
            Assert.AreEqual(3, tree.FindFreeSpan(6));
            Assert.AreEqual(3, tree.FindFreeSpan(7));
            Assert.AreEqual(3, tree.FindFreeSpan(8));
            Assert.AreEqual(3, tree.FindFreeSpan(9));
            Assert.AreEqual(UInt64.MaxValue, tree.FindFreeSpan(10));

            tree.Allocate(6, 2);
            Assert.AreEqual(9, tree.TotalFreeSpace());
            Assert.AreEqual(4, tree.LargestFreeSpan());
            Assert.AreEqual(0, tree.FindFreeSpan(1));
            Assert.AreEqual(0, tree.FindFreeSpan(2));
            Assert.AreEqual(3, tree.FindFreeSpan(3));
            Assert.AreEqual(8, tree.FindFreeSpan(4));
            Assert.AreEqual(UInt64.MaxValue, tree.FindFreeSpan(5));
        }