/** * Inserts an intersecting range after current in the list and adjusts offset accordingly. * @param other the new element to insert * @return the new element. */ public DiskRangeList insertPartAfter(DiskRangeList other) { // The only allowed non-overlapping option is extra bytes at the end. if (other.offset > this.end || other.offset <= this.offset || other.end <= this.offset) { assertInvalidOrder(this.prev == null ? this : this.prev, this, other); } this.end = other.offset; return insertAfter(other); }
private final static void checkOrder(DiskRangeList prev, DiskRangeList next, DiskRangeList ref) { if (prev.getEnd() <= next.getOffset()) return; assertInvalidOrder(ref.prev == null ? ref : ref.prev, prev, next); }
/** * Inserts an intersecting range before current in the list and adjusts offset accordingly. * @param other the element to insert * @return the new element. */ public DiskRangeList insertPartBefore(DiskRangeList other) { checkArg(other); if (other.end <= this.offset || other.end > this.end) { assertInvalidOrder(this.prev == null ? this : this.prev, other, this); } this.offset = other.end; other.prev = this.prev; other.next = this; if (this.prev != null) { checkOrder(this.prev, other, this.prev); this.prev.next = other; } this.prev = other; return other; }
/** * Inserts an intersecting range after current in the list and adjusts offset accordingly. * @param other the new element to insert * @return the new element. */ public DiskRangeList insertPartAfter(DiskRangeList other) { // The only allowed non-overlapping option is extra bytes at the end. if (other.offset > this.end || other.offset <= this.offset || other.end <= this.offset) { assertInvalidOrder(this.prev == null ? this : this.prev, this, other); } this.end = other.offset; return insertAfter(other); }
private final static void checkOrder(DiskRangeList prev, DiskRangeList next, DiskRangeList ref) { if (prev.getEnd() <= next.getOffset()) return; assertInvalidOrder(ref.prev == null ? ref : ref.prev, prev, next); }
/** * Inserts an intersecting range before current in the list and adjusts offset accordingly. * @param other the element to insert * @return the new element. */ public DiskRangeList insertPartBefore(DiskRangeList other) { checkArg(other); if (other.end <= this.offset || other.end > this.end) { assertInvalidOrder(this.prev == null ? this : this.prev, other, this); } this.offset = other.end; other.prev = this.prev; other.next = this; if (this.prev != null) { checkOrder(this.prev, other, this.prev); this.prev.next = other; } this.prev = other; return other; }