/** * @return the new range(s) to Replace the supplied ones. <code>null</code> if no merge Is possible */ private static CellRange[] MergeRanges(CellRange range1, CellRange range2) { int x = range1.intersect(range2); switch (x) { case CellRange.NO_INTERSECTION: if (range1.HasExactSharedBorder(range2)) { return(new CellRange[] { range1.CreateEnclosingCellRange(range2), }); } // else - No intersection and no shared border: do nothing return(null); case CellRange.OVERLAP: return(resolveRangeOverlap(range1, range2)); case CellRange.INSIDE: // Remove range2, since it Is completely inside of range1 return(new CellRange[] { range1, }); case CellRange.ENCLOSES: // range2 encloses range1, so Replace it with the enclosing one return(new CellRange[] { range2, }); } throw new Exception("unexpected intersection result (" + x + ")"); }
/** * @return the new range(s) to Replace the supplied ones. <code>null</code> if no merge Is possible */ private static CellRange[] MergeRanges(CellRange range1, CellRange range2) { int x = range1.intersect(range2); switch (x) { case CellRange.NO_INTERSECTION: if (range1.HasExactSharedBorder(range2)) { return new CellRange[] { range1.CreateEnclosingCellRange(range2), }; } // else - No intersection and no shared border: do nothing return null; case CellRange.OVERLAP: return resolveRangeOverlap(range1, range2); case CellRange.INSIDE: // Remove range2, since it Is completely inside of range1 return new CellRange[] { range1, }; case CellRange.ENCLOSES: // range2 encloses range1, so Replace it with the enclosing one return new CellRange[] { range2, }; } throw new Exception("unexpected intersection result (" + x + ")"); }