Example #1
0
        public static FileRegion GetInclusion(FileRegion region1, FileRegion region2)
        {
            long inclusionStartOffset = Math.Min(region1.Offset, region2.Offset);
            long inclusionEndOffset   = Math.Max(region1.GetEndOffset(), region2.GetEndOffset());
            long inclusionSize        = inclusionEndOffset - inclusionStartOffset;

            return(new FileRegion(inclusionStartOffset, inclusionSize));
        }
Example #2
0
        public static FileRegion GetIntersection(FileRegion region1, FileRegion region2)
        {
            if (!region1.Intersects(region2))
            {
                return(new FileRegion());
            }

            long intersectionStartOffset = Math.Max(region1.Offset, region2.Offset);
            long intersectionEndOffset   = Math.Min(region1.GetEndOffset(), region2.GetEndOffset());
            long intersectionSize        = intersectionEndOffset - intersectionStartOffset;

            return(new FileRegion(intersectionStartOffset, intersectionSize));
        }
Example #3
0
 public static bool HasIntersection(FileRegion region1, FileRegion region2)
 {
     return(region1.GetEndOffset() >= region2.Offset &&
            region2.GetEndOffset() >= region1.Offset);
 }
Example #4
0
 public FileRegion GetIntersection(FileRegion other)
 {
     return(GetIntersection(this, other));
 }
Example #5
0
 public bool Intersects(FileRegion other)
 {
     return(HasIntersection(this, other));
 }
Example #6
0
 public bool Includes(FileRegion other)
 {
     return(Offset <= other.Offset && other.GetEndOffset() <= GetEndOffset());
 }