示例#1
0
 public IEnumerable <KeyValuePair <SectorRange, ISector> > Segment(SectorRange currentRange, IEnumerable <SectorRange> newRanges)
 {
     foreach (var piece in newRanges)
     {
         yield return(piece.PairValue(
                          (ISector) new FileSector(
                              path,
                              offset + (piece.startInclusive - currentRange.startInclusive),
                              piece.endExclusive - piece.startInclusive
                              )
                          ));
     }
 }
        public void DeleteRange(SectorRange range)
        {
            var kvpsToTouch = GetSectorsForRange(range);

            foreach (var kvp in kvpsToTouch)
            {
                sectors.Remove(kvp.Key);
                if (!range.FullyContains(kvp.Key))
                {
                    var newPieces          = kvp.Key.Chop(range);
                    var newRangeAndSectors = kvp.Value.Segment(kvp.Key, newPieces);
                    foreach (var rangeAndSector in newRangeAndSectors)
                    {
                        sectors.Add(rangeAndSector.Key, rangeAndSector.Value);
                    }
                }
            }
        }
示例#3
0
 public IEnumerable <KeyValuePair <SectorRange, ISector> > Segment(SectorRange currentRange, IEnumerable <SectorRange> newRanges)
 {
     return(newRanges.Select(range => range.PairValue((ISector) new NullSector(range.Size))));
 }
 public KeyValuePair <SectorRange, ISector>[] GetSectorsForRange(SectorRange range)
 {
     return(sectors.Where(kvp => range.Intersects(kvp.Key)).ToArray());
 }
 public void AssignSector(SectorRange range, ISector sector)
 {
     DeleteRange(range);
     sectors.Add(range, sector);
 }