Class RangeUtils
java.lang.Object
org.aksw.commons.util.range.RangeUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <I extends Comparable<I>, O extends Comparable<O>, V>
com.google.common.collect.Range<O> apply(com.google.common.collect.Range<I> range, V value, BiFunction<? super I, ? super V, ? extends O> op) Apply a binary operator (e.g.static <C extends Comparable<C>>
intcompareToLowerBound(com.google.common.collect.Range<C> a, com.google.common.collect.Range<C> b) Compare the lower bounds of two canonical ranges.static <C extends Comparable<C>>
intcompareToUpperBound(com.google.common.collect.Range<C> a, com.google.common.collect.Range<C> b) Compare the upper bounds of two canonical ranges.computeRange(com.google.common.collect.Range<Long> range, long pageSize) static <T extends Comparable<T>>
com.google.common.collect.Range<T> Create a range from two endpoints.static <T extends Comparable<T>>
com.google.common.collect.Range<T> create(T lower, com.google.common.collect.BoundType lowerType, T upper, com.google.common.collect.BoundType upperType) Create method similar toRange.range(Comparable, BoundType, Comparable, BoundType)with the difference thatnullcan be used as values in order to denote 'below/above all'.static com.google.common.collect.Range<Long> createRange(Long limit, Long offset) Create a range from limit and offset.static <C extends Comparable<C>>
com.google.common.collect.RangeSet<C> gaps(com.google.common.collect.Range<C> request, com.google.common.collect.RangeSet<C> ranges) Compute the set of gaps for the given request range.static <K extends Comparable<K>, V>
Set<Map.Entry<com.google.common.collect.Range<K>, V>> getIntersectingRanges(com.google.common.collect.Range<K> r, Collection<Map.Entry<com.google.common.collect.Range<K>, V>> ranges) static <T extends Comparable<T>>
Endpoint<T> getLowerEndpoint(com.google.common.collect.Range<T> range) static <T extends Comparable<T>>
Endpoint<T> getUpperEndpoint(com.google.common.collect.Range<T> range) static intstatic booleanisDiscrete(com.google.common.collect.RangeSet<?> rangeSet) True iff all ranges are singletonsstatic booleanisDiscrete(Collection<? extends com.google.common.collect.Range<?>> ranges) static booleanisSingleton(com.google.common.collect.Range<?> range) static booleanisSingleton(com.google.common.collect.RangeSet<?> rangeSet) static booleanisSingleton(Collection<? extends com.google.common.collect.Range<?>> ranges) static <C extends Comparable<C>>
com.google.common.collect.Range<C> makeAbsolute(com.google.common.collect.Range<C> outer, com.google.common.collect.Range<C> relative, com.google.common.collect.DiscreteDomain<C> domain, BiFunction<C, Long, C> addition) Convert a range relative within another one to an absolute rangestatic <I extends Comparable<I>, O extends Comparable<O>>
com.google.common.collect.Range<O> map(com.google.common.collect.Range<I> range, BiFunction<? super I, com.google.common.collect.BoundType, Endpoint<? extends O>> lowerEndpointMapper, BiFunction<? super I, com.google.common.collect.BoundType, Endpoint<? extends O>> upperEndpointMapper) Return a new range with each lower and upper endpoint of the input range passed through a separate transformation function.static <I extends Comparable<I>, O extends Comparable<O>>
com.google.common.collect.Range<O> Return a new range with each concrete endpoint of the input range passed through a transformation functionstatic com.google.common.collect.Range<Long> multiplyByPageSize(com.google.common.collect.Range<Long> range, long pageSize) static doublepickDouble(com.google.common.collect.Range<Double> range, Random random) static longstatic doublerandomDouble(com.google.common.collect.Range<? extends Number> range, Random random) Return a random double value within the given range.static NavigableMap<Long, Long> scheduleRangeSupply(NavigableMap<Long, Long> supplyOffsetToEndpoint, com.google.common.collect.RangeSet<Long> demandGaps, long maxRedundantSize, long maxSupplierRange) Given a map [start, end) pairs (start inclusive, end exclusive) of initial suppliers, return a schedule that covers the set of gaps.static <C extends Comparable<C>>
com.google.common.collect.Range<C> shift(com.google.common.collect.Range<C> rawRange, long distance, com.google.common.collect.DiscreteDomain<C> domain, BiFunction<C, Long, C> addition) static com.google.common.collect.Range<Long> static longstatic com.google.common.collect.Range<Long> startFromZero(com.google.common.collect.Range<Long> range) streamEnclosingRanges(NavigableMap<Long, Long> offsetToEndpoint, long start, long end) Streams all enclosing ranges (if any) ordered by decreasing offset based on offsetToKeystatic <T> List<T> static CountInfotoCountInfo(com.google.common.collect.Range<? extends Number> range) static <T extends Comparable<T>>
Optional<T> tryGetSingleton(com.google.common.collect.Range<T> range)
-
Field Details
-
rangeStartingWithZero
-
RANGE_LONG
-
-
Constructor Details
-
RangeUtils
public RangeUtils()
-
-
Method Details
-
sizeLong
-
intLength
-
subList
-
tryGetSingleton
public static <T extends Comparable<T>> Optional<T> tryGetSingleton(com.google.common.collect.Range<T> range) -
isDiscrete
public static boolean isDiscrete(com.google.common.collect.RangeSet<?> rangeSet) True iff all ranges are singletons -
isDiscrete
-
isSingleton
public static boolean isSingleton(com.google.common.collect.RangeSet<?> rangeSet) -
isSingleton
-
isSingleton
public static boolean isSingleton(com.google.common.collect.Range<?> range) -
pickLong
-
pickDouble
-
toCountInfo
-
makeAbsolute
public static <C extends Comparable<C>> com.google.common.collect.Range<C> makeAbsolute(com.google.common.collect.Range<C> outer, com.google.common.collect.Range<C> relative, com.google.common.collect.DiscreteDomain<C> domain, BiFunction<C, Long, C> addition) Convert a range relative within another one to an absolute range- Parameters:
outer-relative-domain-addition-- Returns:
-
shiftLong
-
shift
public static <C extends Comparable<C>> com.google.common.collect.Range<C> shift(com.google.common.collect.Range<C> rawRange, long distance, com.google.common.collect.DiscreteDomain<C> domain, BiFunction<C, Long, C> addition) -
getIntersectingRanges
public static <K extends Comparable<K>, V> Set<Map.Entry<com.google.common.collect.Range<K>, V>> getIntersectingRanges(com.google.common.collect.Range<K> r, Collection<Map.Entry<com.google.common.collect.Range<K>, V>> ranges) -
startFromZero
-
apply
public static <I extends Comparable<I>, O extends Comparable<O>, V> com.google.common.collect.Range<O> apply(com.google.common.collect.Range<I> range, V value, BiFunction<? super I, ? super V, ? extends O> op) Apply a binary operator (e.g. multiplication, addition, ...) to any endpoint of the range and a given value.- Type Parameters:
I-- Parameters:
range-value-op-- Returns:
-
map
public static <I extends Comparable<I>, O extends Comparable<O>> com.google.common.collect.Range<O> map(com.google.common.collect.Range<I> range, Function<? super I, ? extends O> mapper) Return a new range with each concrete endpoint of the input range passed through a transformation function -
map
public static <I extends Comparable<I>, O extends Comparable<O>> com.google.common.collect.Range<O> map(com.google.common.collect.Range<I> range, BiFunction<? super I, com.google.common.collect.BoundType, Endpoint<? extends O>> lowerEndpointMapper, BiFunction<? super I, com.google.common.collect.BoundType, Endpoint<? extends O>> upperEndpointMapper) Return a new range with each lower and upper endpoint of the input range passed through a separate transformation function. The lower and upper endpoint mappers may return null to indicate the absence of a lower or upper bound in the mapped range, respectively. -
multiplyByPageSize
-
computeRange
-
gaps
public static <C extends Comparable<C>> com.google.common.collect.RangeSet<C> gaps(com.google.common.collect.Range<C> request, com.google.common.collect.RangeSet<C> ranges) Compute the set of gaps for the given request range. This is the complement of the given ranges constrained to the request range. -
createRange
-
create
public static <T extends Comparable<T>> com.google.common.collect.Range<T> create(T lower, com.google.common.collect.BoundType lowerType, T upper, com.google.common.collect.BoundType upperType) Create method similar toRange.range(Comparable, BoundType, Comparable, BoundType)with the difference thatnullcan be used as values in order to denote 'below/above all'. The respective bound type is then ignored. -
create
public static <T extends Comparable<T>> com.google.common.collect.Range<T> create(Endpoint<? extends T> lower, Endpoint<? extends T> upper) Create a range from two endpoints. If either an endpoint or it's value is null then it is considered as unbounded. -
getLowerEndpoint
public static <T extends Comparable<T>> Endpoint<T> getLowerEndpoint(com.google.common.collect.Range<T> range) -
getUpperEndpoint
public static <T extends Comparable<T>> Endpoint<T> getUpperEndpoint(com.google.common.collect.Range<T> range) -
compareToLowerBound
public static <C extends Comparable<C>> int compareToLowerBound(com.google.common.collect.Range<C> a, com.google.common.collect.Range<C> b) Compare the lower bounds of two canonical ranges. This means the bound type is ignored. If both endpoints are absent they are considered equal and the result is 0 -
compareToUpperBound
public static <C extends Comparable<C>> int compareToUpperBound(com.google.common.collect.Range<C> a, com.google.common.collect.Range<C> b) Compare the upper bounds of two canonical ranges. This means the bound type is ignored. If both endpoints are absent they are considered equal and the result is 0 -
randomDouble
-