From 654a4018c456d3aeb7f6d9e6e7aa4b97b45f3fb0 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Sat, 2 Feb 2008 18:17:19 +0000 Subject: [PATCH] make sure immutable PointCostPair internal representation is not accessible JIRA: MATH-183 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@617855 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/math/optimization/PointCostPair.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/java/org/apache/commons/math/optimization/PointCostPair.java b/src/java/org/apache/commons/math/optimization/PointCostPair.java index 6211fd11f..4e4bd4fbd 100644 --- a/src/java/org/apache/commons/math/optimization/PointCostPair.java +++ b/src/java/org/apache/commons/math/optimization/PointCostPair.java @@ -25,7 +25,8 @@ package org.apache.commons.math.optimization; public class PointCostPair { /** Build a point/cost pair. - * @param point point coordinates + * @param point point coordinates (the built instance will store + * a copy of the array, not the array passed as argument) * @param cost point cost */ public PointCostPair(double[] point, double cost) { @@ -34,10 +35,10 @@ public class PointCostPair { } /** Get the point. - * @return the stored point + * @return a copy of the stored point */ public double[] getPoint() { - return point; + return (double[]) point.clone(); } /** Get the cost.