commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From celes...@apache.org
Subject svn commit: r1343547 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayRealVector.java
Date Tue, 29 May 2012 05:36:20 GMT
Author: celestin
Date: Tue May 29 05:36:19 2012
New Revision: 1343547

URL: http://svn.apache.org/viewvc?rev=1343547&view=rev
Log:
MATH-792: implementation of the visitor pattern for ArrayRealVector (overrides
default implementation in RealVector).

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayRealVector.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayRealVector.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayRealVector.java?rev=1343547&r1=1343546&r2=1343547&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayRealVector.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/linear/ArrayRealVector.java
Tue May 29 05:36:19 2012
@@ -881,4 +881,90 @@ public class ArrayRealVector extends Rea
         }
         return this;
     }
+
+    /** {@inheritDoc} */
+    @Override
+    public double walkInDefaultOrder(final RealVectorPreservingVisitor visitor) {
+        visitor.start(data.length, 0, data.length - 1);
+        for (int i = 0; i < data.length; i++) {
+            visitor.visit(i, data[i]);
+        }
+        return visitor.end();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public double walkInDefaultOrder(final RealVectorPreservingVisitor visitor,
+        final int start, final int end) {
+        checkIndices(start, end);
+        visitor.start(data.length, start, end);
+        for (int i = start; i <= end; i++) {
+            visitor.visit(i, data[i]);
+        }
+        return visitor.end();
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * In this implementation, the optimized order is the default order.
+     */
+    @Override
+    public double walkInOptimizedOrder(final RealVectorPreservingVisitor visitor) {
+        return walkInDefaultOrder(visitor);
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * In this implementation, the optimized order is the default order.
+     */
+    @Override
+    public double walkInOptimizedOrder(final RealVectorPreservingVisitor visitor,
+        final int start, final int end) {
+        return walkInDefaultOrder(visitor, start, end);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public double walkInDefaultOrder(final RealVectorChangingVisitor visitor) {
+        visitor.start(data.length, 0, data.length - 1);
+        for (int i = 0; i < data.length; i++) {
+            data[i] = visitor.visit(i, data[i]);
+        }
+        return visitor.end();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public double walkInDefaultOrder(final RealVectorChangingVisitor visitor,
+        final int start, final int end) {
+        checkIndices(start, end);
+        visitor.start(data.length, start, end);
+        for (int i = start; i <= end; i++) {
+            data[i] = visitor.visit(i, data[i]);
+        }
+        return visitor.end();
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * In this implementation, the optimized order is the default order.
+     */
+    @Override
+    public double walkInOptimizedOrder(final RealVectorChangingVisitor visitor) {
+        return walkInDefaultOrder(visitor);
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * In this implementation, the optimized order is the default order.
+     */
+    @Override
+    public double walkInOptimizedOrder(final RealVectorChangingVisitor visitor,
+        final int start, final int end) {
+        return walkInDefaultOrder(visitor, start, end);
+    }
 }



Mime
View raw message