public static <T extends RingPosition<T>> Boundary<T> minRight(Boundary<T> right1, Boundary<T> right2) { int c = right1.boundary.compareTo(right2.boundary); if (c != 0) return c < 0 ? right1 : right2; // return the exclusive version, if either return right2.inclusive ? right1 : right2; }
/** * Tells if the given range is a wrap around. */ public static <T extends RingPosition<T>> boolean isWrapAround(T left, T right) { return left.compareTo(right) >= 0; }
public int compare(Bounds<T> o1, Bounds<T> o2) { return o1.left.compareTo(o2.left); } });
public static <T extends RingPosition<T>> boolean isEmpty(Boundary<T> left, Boundary<T> right) { int c = left.boundary.compareTo(right.boundary); return c > 0 || (c == 0 && !(left.inclusive && right.inclusive)); }
public int compare(Bounds<T> o1, Bounds<T> o2) { return o1.left.compareTo(o2.left); } });
public static <T extends RingPosition<T>> Boundary<T> maxLeft(Boundary<T> left1, Boundary<T> left2) { int c = left1.boundary.compareTo(left2.boundary); if (c != 0) return c > 0 ? left1 : left2; // return the exclusive version, if either return left2.inclusive ? left1 : left2; } }
public static <T extends RingPosition<T>> Boundary<T> maxLeft(Boundary<T> left1, Boundary<T> left2) { int c = left1.boundary.compareTo(left2.boundary); if (c != 0) return c > 0 ? left1 : left2; // return the exclusive version, if either return left2.inclusive ? left1 : left2; } }
public int compare(Range<T> b1, Range<T> b2) { return b1.left.compareTo(b2.left); } });
public int compare(Range<T> b1, Range<T> b2) { return b1.left.compareTo(b2.left); } });
/** * Tells if the given range is a wrap around. */ public static <T extends RingPosition<T>> boolean isWrapAround(T left, T right) { return left.compareTo(right) >= 0; }
public int compare(Bounds<T> o1, Bounds<T> o2) { return o1.left.compareTo(o2.left); } });
public Bounds(T left, T right, IPartitioner partitioner) { super(left, right, partitioner); // unlike a Range, a Bounds may not wrap assert left.compareTo(right) <= 0 || right.isMinimum(partitioner) : "[" + left + "," + right + "]"; }
private static <T extends RingPosition<T>> Set<Range<T>> intersectionBothWrapping(Range<T> first, Range<T> that) { Set<Range<T>> intersection = new HashSet<Range<T>>(2); if (that.right.compareTo(first.left) > 0) intersection.add(new Range<T>(first.left, that.right)); intersection.add(new Range<T>(that.left, first.right)); return Collections.unmodifiableSet(intersection); }
public IncludingExcludingBounds(T left, T right) { super(left, right); // unlike a Range, an IncludingExcludingBounds may not wrap, nor have // right == left unless the right is the min token assert !strictlyWrapsAround(left, right) && (right.isMinimum() || left.compareTo(right) != 0) : "(" + left + "," + right + ")"; }
public IncludingExcludingBounds(T left, T right) { super(left, right); // unlike a Range, an IncludingExcludingBounds may not wrap, nor have // right == left unless the right is the min token assert !strictlyWrapsAround(left, right) && (right.isMinimum() || left.compareTo(right) != 0) : "(" + left + "," + right + ")"; }
public IncludingExcludingBounds(T left, T right) { super(left, right); // unlike a Range, an IncludingExcludingBounds may not wrap, nor have // right == left unless the right is the min token assert !strictlyWrapsAround(left, right) && (right.isMinimum() || left.compareTo(right) != 0) : "(" + left + "," + right + ")"; }
public ExcludingBounds(T left, T right) { super(left, right); // unlike a Range, an ExcludingBounds may not wrap, nor be empty assert !strictlyWrapsAround(left, right) && (right.isMinimum() || left.compareTo(right) != 0) : "(" + left + "," + right + ")"; }
public ExcludingBounds(T left, T right) { super(left, right); // unlike a Range, an ExcludingBounds may not wrap, nor be empty assert !strictlyWrapsAround(left, right) && (right.isMinimum() || left.compareTo(right) != 0) : "(" + left + "," + right + ")"; }
private static <T extends RingPosition<T>> Set<Range<T>> intersectionOneWrapping(Range<T> wrapping, Range<T> other) { Set<Range<T>> intersection = new HashSet<Range<T>>(2); if (other.contains(wrapping.right)) intersection.add(new Range<T>(other.left, wrapping.right)); // need the extra compareto here because ranges are asymmetrical; wrapping.left _is not_ contained by the wrapping range if (other.contains(wrapping.left) && wrapping.left.compareTo(other.right) < 0) intersection.add(new Range<T>(wrapping.left, other.right)); return Collections.unmodifiableSet(intersection); }
private static <T extends RingPosition<T>> Set<Range<T>> intersectionOneWrapping(Range<T> wrapping, Range<T> other) { Set<Range<T>> intersection = new HashSet<Range<T>>(2); if (other.contains(wrapping.right)) intersection.add(new Range<T>(other.left, wrapping.right)); // need the extra compareto here because ranges are asymmetrical; wrapping.left _is not_ contained by the wrapping range if (other.contains(wrapping.left) && wrapping.left.compareTo(other.right) < 0) intersection.add(new Range<T>(wrapping.left, other.right)); return Collections.unmodifiableSet(intersection); }