javadoc.com.google.common.collect.DiscreteDomain.html Maven / Gradle / Ivy
The newest version!
DiscreteDomain (Guava: Google Core Libraries for Java 11.0.1 API)
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
com.google.common.collect
Class DiscreteDomain<C extends Comparable>
java.lang.Object
com.google.common.collect.DiscreteDomain<C>
@GwtCompatible
@Beta
public abstract class DiscreteDomain<C extends Comparable>
- extends Object
A descriptor for a discrete Comparable
domain such as all
Integer
s. A discrete domain is one that supports the three basic
operations: next(C)
, previous(C)
and distance(C, C)
, according
to their specifications. The methods minValue()
and maxValue()
should also be overridden for bounded types.
A discrete domain always represents the entire set of values of its type; it cannot represent partial domains such as "prime integers" or "strings of length 5."
- Since:
- 10.0
- Author:
- Kevin Bourrillion
- See Also:
DiscreteDomains
Constructor Summary | |
---|---|
protected |
DiscreteDomain()
Constructor for use by subclasses. |
Method Summary | |
---|---|
abstract long |
distance(C start,
C end)
Returns a signed value indicating how many nested invocations of next(C) (if positive) or previous(C) (if negative) are needed to reach
end starting from start . |
C |
maxValue()
Returns the maximum value of type C , if it has one. |
C |
minValue()
Returns the minimum value of type C , if it has one. |
abstract C |
next(C value)
Returns the unique least value of type C that is greater than
value , or null if none exists. |
abstract C |
previous(C value)
Returns the unique greatest value of type C that is less than
value , or null if none exists. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
DiscreteDomain
protected DiscreteDomain()
- Constructor for use by subclasses.
Method Detail |
---|
next
public abstract C next(C value)
- Returns the unique least value of type
C
that is greater thanvalue
, ornull
if none exists. Inverse operation toprevious(C)
.- Parameters:
value
- any value of typeC
- Returns:
- the least value greater than
value
, ornull
ifvalue
ismaxValue()
previous
public abstract C previous(C value)
- Returns the unique greatest value of type
C
that is less thanvalue
, ornull
if none exists. Inverse operation tonext(C)
.- Parameters:
value
- any value of typeC
- Returns:
- the greatest value less than
value
, ornull
ifvalue
isminValue()
distance
public abstract long distance(C start, C end)
- Returns a signed value indicating how many nested invocations of
next(C)
(if positive) orprevious(C)
(if negative) are needed to reachend
starting fromstart
. For example, ifend = next(next(next(start)))
, thendistance(start, end) == 3
anddistance(end, start) == -3
. As well,distance(a, a)
is always zero.Note that this function is necessarily well-defined for any discrete type.
- Returns:
- the distance as described above, or
Long.MIN_VALUE
orLong.MIN_VALUE
if the distance is too small or too large, respectively.
minValue
public C minValue()
- Returns the minimum value of type
C
, 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
.- Returns:
- the minimum value of type
C
; never null - Throws:
NoSuchElementException
- if the type has no (practical) minimum value; for example,BigInteger
maxValue
public C maxValue()
- Returns the maximum value of type
C
, 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
.- Returns:
- the maximum value of type
C
; never null - Throws:
NoSuchElementException
- if the type has no (practical) maximum value; for example,BigInteger
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2010-2012. All Rights Reserved.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy