/** * Inserts an element after current in the list. * @param other the new element to insert * @return the new element. * */ public DiskRangeList insertAfter(DiskRangeList other) { checkArg(other); checkOrder(this, other, this); return insertAfterInternal(other); }
/** Replaces this element with another in the list; returns the new element. * @param other the disk range to swap into this list * @return the new element */ public DiskRangeList replaceSelfWith(DiskRangeList other) { checkArg(other); other.prev = this.prev; other.next = this.next; if (this.prev != null) { checkOrder(this.prev, other, this); this.prev.next = other; } if (this.next != null) { checkOrder(other, this.next, this); this.next.prev = other; } this.next = this.prev = null; return other; }
/** * 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 element after current in the list. * @param other the new element to insert * @return the new element. * */ public DiskRangeList insertAfter(DiskRangeList other) { checkArg(other); checkOrder(this, other, this); return insertAfterInternal(other); }
/** * 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; }
/** Replaces this element with another in the list; returns the new element. * @param other the disk range to swap into this list * @return the new element */ public DiskRangeList replaceSelfWith(DiskRangeList other) { checkArg(other); other.prev = this.prev; other.next = this.next; if (this.prev != null) { checkOrder(this.prev, other, this); this.prev.next = other; } if (this.next != null) { checkOrder(other, this.next, this); this.next.prev = other; } this.next = this.prev = null; return other; }