Beispiel #1
0
        protected void Fix_Block_Position_In_Groups(Block block, long old_Address, long new_Address, int old_Length, int new_Length)
        {
            int index = -1;

            for (int i = 0; i < Empty_Slots.Count; i++)
            {
                if (Empty_Slots[i].Length == old_Length)
                {
                    index = i;
                }
            }

            var group = Empty_Slots[index];

            group.Blocks.Remove(old_Address);

            if (group.Blocks.Count == 0)
            {
                Empty_Slots.RemoveAt(index);
            }
            if (new_Length == 0)
            {
                return;
            }

            index = -1;
            for (int i = 0; i < Empty_Slots.Count; i++)
            {
                if (Empty_Slots[i].Length == new_Length)
                {
                    index = i;
                }
            }

            if (index == -1)
            {
                group = new Block_Group {
                    Length = new_Length, Blocks = new Dictionary <long, Block>()
                };
                Empty_Slots.Add(group);
            }
            else
            {
                group = Empty_Slots[index];
            }
            group.Blocks[new_Address] = block;
        }
Beispiel #2
0
        protected void Insert_Block(long address, int lenght)
        {
            var group = Find_Block_Group(lenght);

            if (group == null)
            {
                group = new Block_Group()
                {
                    Length = lenght, Blocks = new Dictionary <long, Block>()
                };
                Empty_Slots.Add(group.Value);
            }

            var block = new Block(address, lenght);

            group.Value.Blocks[address] = block;

            _base_Address_Index[address]            = block;
            _end_Address_Index[block.End_Address()] = block;
        }