Package com.google.common.collect
Class GeneralRange<T>
- java.lang.Object
-
- com.google.common.collect.GeneralRange<T>
-
- All Implemented Interfaces:
java.io.Serializable
final class GeneralRange<T> extends java.lang.Object implements java.io.SerializableA generalized interval on any ordering, for internal use. Supportsnull. UnlikeRange, this allows the use of an arbitrary comparator. This is designed for use in the implementation of subcollections of sorted collection types.Whenever possible, use
Rangeinstead, which is better supported.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Comparator<? super T>comparatorprivate booleanhasLowerBoundprivate booleanhasUpperBoundprivate BoundTypelowerBoundTypeprivate TlowerEndpointprivate GeneralRange<T>reverseprivate BoundTypeupperBoundTypeprivate TupperEndpoint
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static <T> GeneralRange<T>all(java.util.Comparator<? super T> comparator)Returns the whole range relative to the specified comparator.(package private) java.util.Comparator<? super T>comparator()(package private) booleancontains(T t)(package private) static <T> GeneralRange<T>downTo(java.util.Comparator<? super T> comparator, T endpoint, BoundType boundType)Returns everything above the endpoint relative to the specified comparator, with the specified endpoint behavior.booleanequals(java.lang.Object obj)(package private) static <T extends java.lang.Comparable>
GeneralRange<T>from(Range<T> range)Converts a Range to a GeneralRange.(package private) BoundTypegetLowerBoundType()(package private) TgetLowerEndpoint()(package private) BoundTypegetUpperBoundType()(package private) TgetUpperEndpoint()inthashCode()(package private) booleanhasLowerBound()(package private) booleanhasUpperBound()(package private) GeneralRange<T>intersect(GeneralRange<T> other)Returns the intersection of the two ranges, or an empty range if their intersection is empty.(package private) booleanisEmpty()(package private) static <T> GeneralRange<T>range(java.util.Comparator<? super T> comparator, T lower, BoundType lowerType, T upper, BoundType upperType)Returns everything between the endpoints relative to the specified comparator, with the specified endpoint behavior.(package private) GeneralRange<T>reverse()Returns the same range relative to the reversed comparator.(package private) booleantooHigh(T t)(package private) booleantooLow(T t)java.lang.StringtoString()(package private) static <T> GeneralRange<T>upTo(java.util.Comparator<? super T> comparator, T endpoint, BoundType boundType)Returns everything below the endpoint relative to the specified comparator, with the specified endpoint behavior.
-
-
-
Field Detail
-
comparator
private final java.util.Comparator<? super T> comparator
-
hasLowerBound
private final boolean hasLowerBound
-
lowerEndpoint
private final T lowerEndpoint
-
lowerBoundType
private final BoundType lowerBoundType
-
hasUpperBound
private final boolean hasUpperBound
-
upperEndpoint
private final T upperEndpoint
-
upperBoundType
private final BoundType upperBoundType
-
reverse
private transient GeneralRange<T> reverse
-
-
Method Detail
-
from
static <T extends java.lang.Comparable> GeneralRange<T> from(Range<T> range)
Converts a Range to a GeneralRange.
-
all
static <T> GeneralRange<T> all(java.util.Comparator<? super T> comparator)
Returns the whole range relative to the specified comparator.
-
downTo
static <T> GeneralRange<T> downTo(java.util.Comparator<? super T> comparator, T endpoint, BoundType boundType)
Returns everything above the endpoint relative to the specified comparator, with the specified endpoint behavior.
-
upTo
static <T> GeneralRange<T> upTo(java.util.Comparator<? super T> comparator, T endpoint, BoundType boundType)
Returns everything below the endpoint relative to the specified comparator, with the specified endpoint behavior.
-
range
static <T> GeneralRange<T> range(java.util.Comparator<? super T> comparator, T lower, BoundType lowerType, T upper, BoundType upperType)
Returns everything between the endpoints relative to the specified comparator, with the specified endpoint behavior.
-
comparator
java.util.Comparator<? super T> comparator()
-
hasLowerBound
boolean hasLowerBound()
-
hasUpperBound
boolean hasUpperBound()
-
isEmpty
boolean isEmpty()
-
tooLow
boolean tooLow(T t)
-
tooHigh
boolean tooHigh(T t)
-
contains
boolean contains(T t)
-
intersect
GeneralRange<T> intersect(GeneralRange<T> other)
Returns the intersection of the two ranges, or an empty range if their intersection is empty.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
reverse
GeneralRange<T> reverse()
Returns the same range relative to the reversed comparator.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getLowerEndpoint
T getLowerEndpoint()
-
getLowerBoundType
BoundType getLowerBoundType()
-
getUpperEndpoint
T getUpperEndpoint()
-
getUpperBoundType
BoundType getUpperBoundType()
-
-