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)); }
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)); }
public static bool HasIntersection(FileRegion region1, FileRegion region2) { return(region1.GetEndOffset() >= region2.Offset && region2.GetEndOffset() >= region1.Offset); }
public FileRegion GetIntersection(FileRegion other) { return(GetIntersection(this, other)); }
public bool Intersects(FileRegion other) { return(HasIntersection(this, other)); }
public bool Includes(FileRegion other) { return(Offset <= other.Offset && other.GetEndOffset() <= GetEndOffset()); }