java.lang.Object
io.jenetics.LongGene
- All Implemented Interfaces:
BoundedGene<Long,
,LongGene> Gene<Long,
,LongGene> NumericGene<Long,
,LongGene> Factory<LongGene>
,Mean<LongGene>
,Self<LongGene>
,Verifiable
,Serializable
,Comparable<LongGene>
public final class LongGene
extends Object
implements NumericGene<Long,LongGene>, Mean<LongGene>, Comparable<LongGene>, Serializable
NumericGene implementation which holds a 64-bit integer number.
This is a
value-based class; use of identity-sensitive operations (including
reference equality (==
), identity hash code, or synchronization) on
instances of LongGene
may have unpredictable results and should
be avoided.
- Since:
- 1.6
- Version:
- 6.1
- See Also:
- Implementation Note:
- This class is immutable and thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionallele()
Return the allele of this gene.byte
Returns the value of the specified gene as a byte.int
double
Returns the value of the specified gene as a double.boolean
float
Returns the value of the specified gene as a float.int
hashCode()
int
intValue()
Returns the value of the specified gene as an int.boolean
isValid()
Check if this object is valid.long
Returns the value of the specified gene as a long.max()
Return the allowed max value.Return the (usually arithmetic) mean value ofthis
andthat
.min()
Return the allowed min value.Return a new, random gene with the same type and with the same constraints as this gene.newInstance
(long allele) Create a new gene from the givenvalue
and the gene context.newInstance
(Long allele) Create a new gene from the givenvalue
and the current bounds.newInstance
(Number allele) Create a new gene from the givenvalue
and the current bounds.static LongGene
of
(long min, long max) Create a new randomLongGene
.static LongGene
of
(long allele, long min, long max) Create a new randomLongGene
with the given value and the given range.static LongGene
Create a new randomLongGene
with the given value and the given range.static LongGene
Create a new randomLongGene
.range()
Return the range ofthis
gene.short
Returns the value of the specified gene as a short.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.jenetics.BoundedGene
max, min
-
Method Details
-
allele
Description copied from interface:Gene
Return the allele of this gene. -
min
Description copied from interface:BoundedGene
Return the allowed min value.- Specified by:
min
in interfaceBoundedGene<Long,
LongGene> - Returns:
- The allowed min value.
-
max
Description copied from interface:BoundedGene
Return the allowed max value.- Specified by:
max
in interfaceBoundedGene<Long,
LongGene> - Returns:
- The allowed max value.
-
range
Return the range ofthis
gene.- Returns:
- the range of
this
gene - Since:
- 4.4
-
byteValue
Description copied from interface:NumericGene
Returns the value of the specified gene as a byte. This may involve rounding or truncation.- Specified by:
byteValue
in interfaceNumericGene<Long,
LongGene> - Returns:
- the numeric value represented by this object after conversion to
type
byte
.
-
shortValue
Description copied from interface:NumericGene
Returns the value of the specified gene as a short. This may involve rounding or truncation.- Specified by:
shortValue
in interfaceNumericGene<Long,
LongGene> - Returns:
- the numeric value represented by this object after conversion to
type
short
.
-
intValue
Description copied from interface:NumericGene
Returns the value of the specified gene as an int. This may involve rounding or truncation.- Specified by:
intValue
in interfaceNumericGene<Long,
LongGene> - Returns:
- the numeric value represented by this object after conversion to
type
int
.
-
longValue
Description copied from interface:NumericGene
Returns the value of the specified gene as a long. This may involve rounding or truncation.- Specified by:
longValue
in interfaceNumericGene<Long,
LongGene> - Returns:
- the numeric value represented by this object after conversion to
type
long
.
-
floatValue
Description copied from interface:NumericGene
Returns the value of the specified gene as a float. This may involve rounding or truncation.- Specified by:
floatValue
in interfaceNumericGene<Long,
LongGene> - Returns:
- the numeric value represented by this object after conversion to
type
float
.
-
doubleValue
Description copied from interface:NumericGene
Returns the value of the specified gene as a double. This may involve rounding or truncation.- Specified by:
doubleValue
in interfaceNumericGene<Long,
LongGene> - Returns:
- the numeric value represented by this object after conversion to
type
double
.
-
isValid
Description copied from interface:Verifiable
Check if this object is valid.- Specified by:
isValid
in interfaceBoundedGene<Long,
LongGene> - Specified by:
isValid
in interfaceVerifiable
- Returns:
- true if this object is valid, false otherwise.
-
compareTo
- Specified by:
compareTo
in interfaceBoundedGene<Long,
LongGene> - Specified by:
compareTo
in interfaceComparable<LongGene>
-
mean
Description copied from interface:Mean
Return the (usually arithmetic) mean value ofthis
andthat
. ForNumericGene
s the mean is the arithmetic mean. -
newInstance
Create a new gene from the givenvalue
and the gene context.- Parameters:
allele
- the value of the new gene.- Returns:
- a new gene with the given value.
- Since:
- 5.0
-
newInstance
Description copied from interface:BoundedGene
Create a new gene from the givenvalue
and the current bounds.- Specified by:
newInstance
in interfaceBoundedGene<Long,
LongGene> - Specified by:
newInstance
in interfaceGene<Long,
LongGene> - Parameters:
allele
- the value of the new gene.- Returns:
- a new gene with the given value.
-
newInstance
Description copied from interface:BoundedGene
Create a new gene from the givenvalue
and the current bounds.- Specified by:
newInstance
in interfaceNumericGene<Long,
LongGene> - Parameters:
allele
- the value of the new gene.- Returns:
- a new gene with the given value.
-
newInstance
Description copied from interface:Gene
Return a new, random gene with the same type and with the same constraints as this gene. For all genes returned by this method holdsgene.getClass() == gene.newInstance().getClass()
. Implementations of this method have to use theRandomGenerator
object which can be fetched from theRandomRegistry
.- Specified by:
newInstance
in interfaceFactory<LongGene>
- Specified by:
newInstance
in interfaceGene<Long,
LongGene> - Returns:
- a new instance of type T
-
hashCode
-
equals
-
toString
-
of
Create a new randomLongGene
with the given value and the given range. If thevalue
isn't within the interval[min, max)
, no exception is thrown. In this case the methodisValid()
returnsfalse
.- Parameters:
allele
- the value of the gene.min
- the minimal valid value of this gene (inclusively).max
- the maximal valid value of this gene (exclusively).- Returns:
- a new
LongGene
with the given parameters.
-
of
Create a new randomLongGene
with the given value and the given range. If thevalue
isn't within the interval[min, max)
, no exception is thrown. In this case the methodisValid()
returnsfalse
.- Parameters:
allele
- the value of the gene.range
- the long range to use- Returns:
- a new random
LongGene
- Throws:
NullPointerException
- if the givenrange
isnull
.- Since:
- 3.2
-
of
Create a new randomLongGene
. It is guaranteed that the value of theLongGene
lies in the interval[min, max)
.- Parameters:
min
- the minimal valid value of this gene (inclusively).max
- the maximal valid value of this gene (exclusively).- Returns:
- a new
LongGene
with the given parameters. - Throws:
IllegalArgumentException
- ifmax
is greater than or equal tomin
-
of
Create a new randomLongGene
. It is guaranteed that the value of theLongGene
lies in the interval[min, max)
.- Parameters:
range
- the long range to use- Returns:
- a new random
LongGene
- Throws:
NullPointerException
- if the givenrange
isnull
IllegalArgumentException
- ifmax
is greater than or equal tomin
- Since:
- 3.2
-