Beispiel #1
0
 private IEnumerable<byte[]> Blocks(IndirectNode indirectNode, int recursion)
 {
     foreach (var blockNumber in indirectNode.UsedBlockNumbers())
     {
         if (recursion == 0) yield return _blockManipulator.ReadBlock(blockNumber);
         else foreach (var bytes in Blocks(ReadIndirectNode(blockNumber), recursion - 1)) yield return bytes;
     }
 }
Beispiel #2
0
        /*private void ReplaceInIndirectNode(IndirectNode indirectNode, long toBeReplaced, long toReplace, int recursion)
        {
            for (var i = 0; i < indirectNode.UsedBlockNumbers().Count(); i++)
            {
                var blockNumber = indirectNode[i];

                if (recursion == 0)
                {
                    // TODO: inspect this: is it needed??
                    if (blockNumber != toBeReplaced) continue;

                    indirectNode[i] = toReplace;
                    _persistence.PersistIndirectNode(indirectNode);
                    return;
                }

                ReplaceInIndirectNode(ReadIndirectNode(blockNumber), toBeReplaced, toReplace, recursion - 1);
            }
        }*/
        private void AddFromIndirectNode(IndirectNode indirectNode, List<IIndexNode> l, int recursion)
        {
            foreach (var blockNumber in indirectNode.UsedBlockNumbers())
            {
                if (recursion == 0) l.Add(ReadIndexNode(blockNumber));
                else AddFromIndirectNode(ReadIndirectNode(blockNumber), l, recursion - 1);
            }
        }