private DiskRangeList insertAfterInternal(DiskRangeList other) { other.next = this.next; other.prev = this; if (this.next != null) { checkOrder(other, this.next, this); this.next.prev = other; } this.next = other; return other; }
public void setEnd(long newEnd) { assert newEnd >= this.offset; assert this.next == null || this.next.offset >= newEnd; this.end = newEnd; if (this.next != null) { checkOrder(this, this.next, this); } } }
/** 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 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; }
/** Splits current element in the list, using DiskRange::slice. * @param cOffset the position to split the list * @return the split list */ public final DiskRangeList split(long cOffset) { DiskRangeList right = insertAfterInternal((DiskRangeList)this.sliceAndShift(cOffset, end, 0)); DiskRangeList left = replaceSelfWith((DiskRangeList)this.sliceAndShift(offset, cOffset, 0)); checkOrder(left, right, left); // Prev/next are already checked in the calls. return left; }
private DiskRangeList insertAfterInternal(DiskRangeList other) { other.next = this.next; other.prev = this; if (this.next != null) { checkOrder(other, this.next, this); this.next.prev = other; } this.next = other; return other; }
public void setEnd(long newEnd) { assert newEnd >= this.offset; assert this.next == null || this.next.offset >= newEnd; this.end = newEnd; if (this.next != null) { checkOrder(this, this.next, this); } } }
/** 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 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; }
/** Splits current element in the list, using DiskRange::slice. * @param cOffset the position to split the list * @return the split list */ public final DiskRangeList split(long cOffset) { DiskRangeList right = insertAfterInternal((DiskRangeList)this.sliceAndShift(cOffset, end, 0)); DiskRangeList left = replaceSelfWith((DiskRangeList)this.sliceAndShift(offset, cOffset, 0)); checkOrder(left, right, left); // Prev/next are already checked in the calls. return left; }