You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2014/01/26 16:46:50 UTC
svn commit: r1561508 - in /commons/proper/math/trunk/src: changes/changes.xml
main/java/org/apache/commons/math3/genetics/AbstractListChromosome.java
Author: tn
Date: Sun Jan 26 15:46:49 2014
New Revision: 1561508
URL: http://svn.apache.org/r1561508
Log:
[MATH-1072] Added constructor for AbstractListChromosome that does not copy the input argument.
Modified:
commons/proper/math/trunk/src/changes/changes.xml
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/AbstractListChromosome.java
Modified: commons/proper/math/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/changes/changes.xml?rev=1561508&r1=1561507&r2=1561508&view=diff
==============================================================================
--- commons/proper/math/trunk/src/changes/changes.xml (original)
+++ commons/proper/math/trunk/src/changes/changes.xml Sun Jan 26 15:46:49 2014
@@ -51,19 +51,23 @@ If the output is not quite correct, chec
</properties>
<body>
<release version="3.3" date="TBD" description="TBD">
+ <action dev="tn" type="add" issue="MATH-1072">
+ Added a constructor to "AbstractListChromosome" that does not copy the
+ input argument.
+ </action>
<action dev="luc" type="add" issue="MATH-1091">
- BSP tree now provides an API to compute a global signed distance from
- a test point to the region. The distance is positive if the point is
- outside of the region, negative if the point is inside, and zero
- when the point is at the boundary. The distance is continuous
- everywhere, so it can be used with a root solver to identify accurately
- boundary crossings. This API is available for all BSP trees, in
- Euclidean and spherical geometries, and in all dimensions.
+ BSP tree now provides an API to compute a global signed distance from
+ a test point to the region. The distance is positive if the point is
+ outside of the region, negative if the point is inside, and zero
+ when the point is at the boundary. The distance is continuous
+ everywhere, so it can be used with a root solver to identify accurately
+ boundary crossings. This API is available for all BSP trees, in
+ Euclidean and spherical geometries, and in all dimensions.
</action>
<action dev="luc" type="add" issue="MATH-1090">
- IntervalsSet now implements Iterable<double[]>, so one can iterate
- over the sub-intervals without building a full list containing
- a copy of everything beforehand.
+ IntervalsSet now implements Iterable<double[]>, so one can iterate
+ over the sub-intervals without building a full list containing
+ a copy of everything beforehand.
</action>
<action dev="tn" type="fix" issue="MATH-1089">
"Precision#round(double, ...)" will now return negative zero for negative
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/AbstractListChromosome.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/AbstractListChromosome.java?rev=1561508&r1=1561507&r2=1561508&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/AbstractListChromosome.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/AbstractListChromosome.java Sun Jan 26 15:46:49 2014
@@ -34,17 +34,16 @@ public abstract class AbstractListChromo
private final List<T> representation;
/**
- * Constructor.
+ * Constructor, copying the input representation.
* @param representation inner representation of the chromosome
* @throws InvalidRepresentationException iff the <code>representation</code> can not represent a valid chromosome
*/
public AbstractListChromosome(final List<T> representation) throws InvalidRepresentationException {
- checkValidity(representation);
- this.representation = Collections.unmodifiableList(new ArrayList<T>(representation));
+ this(representation, true);
}
/**
- * Constructor.
+ * Constructor, copying the input representation.
* @param representation inner representation of the chromosome
* @throws InvalidRepresentationException iff the <code>representation</code> can not represent a valid chromosome
*/
@@ -53,6 +52,17 @@ public abstract class AbstractListChromo
}
/**
+ * Constructor.
+ * @param representation inner representation of the chromosome
+ * @param copyList if {@code true}, the representation will be copied, otherwise it will be referenced.
+ */
+ public AbstractListChromosome(final List<T> representation, final boolean copyList) {
+ checkValidity(representation);
+ this.representation =
+ Collections.unmodifiableList(copyList ? new ArrayList<T>(representation) : representation);
+ }
+
+ /**
* Asserts that <code>representation</code> can represent a valid chromosome.
*
* @param chromosomeRepresentation representation of the chromosome