Package com.google.common.collect
Class DiscreteDomain.IntegerDomain
- java.lang.Object
-
- com.google.common.collect.DiscreteDomain<java.lang.Integer>
-
- com.google.common.collect.DiscreteDomain.IntegerDomain
-
- All Implemented Interfaces:
java.io.Serializable
- Enclosing class:
- DiscreteDomain<C extends java.lang.Comparable>
private static final class DiscreteDomain.IntegerDomain extends DiscreteDomain<java.lang.Integer> implements java.io.Serializable
-
-
Field Summary
Fields Modifier and Type Field Description private static DiscreteDomain.IntegerDomainINSTANCEprivate static longserialVersionUID-
Fields inherited from class com.google.common.collect.DiscreteDomain
supportsFastOffset
-
-
Constructor Summary
Constructors Constructor Description IntegerDomain()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longdistance(java.lang.Integer start, java.lang.Integer end)Returns a signed value indicating how many nested invocations ofDiscreteDomain.next(C)(if positive) orDiscreteDomain.previous(C)(if negative) are needed to reachendstarting fromstart.java.lang.IntegermaxValue()Returns the maximum value of typeC, if it has one.java.lang.IntegerminValue()Returns the minimum value of typeC, if it has one.java.lang.Integernext(java.lang.Integer value)Returns the unique least value of typeCthat is greater thanvalue, ornullif none exists.(package private) java.lang.Integeroffset(java.lang.Integer origin, long distance)Returns, conceptually, "origin + distance", or equivalently, the result of callingDiscreteDomain.next(C)onorigindistancetimes.java.lang.Integerprevious(java.lang.Integer value)Returns the unique greatest value of typeCthat is less thanvalue, ornullif none exists.private java.lang.ObjectreadResolve()java.lang.StringtoString()-
Methods inherited from class com.google.common.collect.DiscreteDomain
bigIntegers, integers, longs
-
-
-
-
Field Detail
-
INSTANCE
private static final DiscreteDomain.IntegerDomain INSTANCE
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
next
public java.lang.Integer next(java.lang.Integer value)
Description copied from class:DiscreteDomainReturns the unique least value of typeCthat is greater thanvalue, ornullif none exists. Inverse operation toDiscreteDomain.previous(C).- Specified by:
nextin classDiscreteDomain<java.lang.Integer>- Parameters:
value- any value of typeC- Returns:
- the least value greater than
value, ornullifvalueismaxValue()
-
previous
public java.lang.Integer previous(java.lang.Integer value)
Description copied from class:DiscreteDomainReturns the unique greatest value of typeCthat is less thanvalue, ornullif none exists. Inverse operation toDiscreteDomain.next(C).- Specified by:
previousin classDiscreteDomain<java.lang.Integer>- Parameters:
value- any value of typeC- Returns:
- the greatest value less than
value, ornullifvalueisminValue()
-
offset
java.lang.Integer offset(java.lang.Integer origin, long distance)Description copied from class:DiscreteDomainReturns, conceptually, "origin + distance", or equivalently, the result of callingDiscreteDomain.next(C)onorigindistancetimes.- Overrides:
offsetin classDiscreteDomain<java.lang.Integer>
-
distance
public long distance(java.lang.Integer start, java.lang.Integer end)Description copied from class:DiscreteDomainReturns a signed value indicating how many nested invocations ofDiscreteDomain.next(C)(if positive) orDiscreteDomain.previous(C)(if negative) are needed to reachendstarting fromstart. For example, ifend = next(next(next(start))), thendistance(start, end) == 3anddistance(end, start) == -3. As well,distance(a, a)is always zero.Note that this function is necessarily well-defined for any discrete type.
- Specified by:
distancein classDiscreteDomain<java.lang.Integer>- Returns:
- the distance as described above, or
Long.MIN_VALUEorLong.MAX_VALUEif the distance is too small or too large, respectively.
-
minValue
public java.lang.Integer minValue()
Description copied from class:DiscreteDomainReturns the minimum value of typeC, if it has one. The minimum value is the unique value for whichComparable.compareTo(Object)never returns a positive value for any input of typeC.The default implementation throws
NoSuchElementException.- Overrides:
minValuein classDiscreteDomain<java.lang.Integer>- Returns:
- the minimum value of type
C; never null
-
maxValue
public java.lang.Integer maxValue()
Description copied from class:DiscreteDomainReturns the maximum value of typeC, if it has one. The maximum value is the unique value for whichComparable.compareTo(Object)never returns a negative value for any input of typeC.The default implementation throws
NoSuchElementException.- Overrides:
maxValuein classDiscreteDomain<java.lang.Integer>- Returns:
- the maximum value of type
C; never null
-
readResolve
private java.lang.Object readResolve()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-