    001    /*
    002     * Licensed to the Apache Software Foundation (ASF) under one or more
    003     * contributor license agreements.  See the NOTICE file distributed with
    004     * this work for additional information regarding copyright ownership.
    005     * The ASF licenses this file to You under the Apache License, Version 2.0
    006     * (the "License"); you may not use this file except in compliance with
    007     * the License.  You may obtain a copy of the License at
    008     *
    009     *      http://www.apache.org/licenses/LICENSE-2.0
    010     *
    011     * Unless required by applicable law or agreed to in writing, software
    012     * distributed under the License is distributed on an "AS IS" BASIS,
    013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014     * See the License for the specific language governing permissions and
    015     * limitations under the License.
    016     */
    017    package org.apache.commons.math3.linear;
    018
    019    /**
    020     * This interface defines a visitor for the entries of a vector. Visitors
    021     * implementing this interface do not alter the entries of the vector being
    022     * visited.
    023     *
    024     * @version $Id: RealVectorPreservingVisitor.java 1416643 2012-12-03 19:37:14Z tn $
    025     * @since 3.1
    026     */
    027    public interface RealVectorPreservingVisitor {
    028        /**
    029         * Start visiting a vector. This method is called once, before any entry
    030         * of the vector is visited.
    031         *
    032         * @param dimension the size of the vector
    033         * @param start the index of the first entry to be visited
    034         * @param end the index of the last entry to be visited (inclusive)
    035         */
    036        void start(int dimension, int start, int end);
    037
    038        /**
    039         * Visit one entry of the vector.
    040         *
    041         * @param index the index of the entry being visited
    042         * @param value the value of the entry being visited
    043         */
    044        void visit(int index, double value);
    045
    046        /**
    047         * End visiting a vector. This method is called once, after all entries of
    048         * the vector have been visited.
    049         *
    050         * @return the value returned by
    051         * {@link RealVector#walkInDefaultOrder(RealVectorPreservingVisitor)},
    052         * {@link RealVector#walkInDefaultOrder(RealVectorPreservingVisitor, int, int)},
    053         * {@link RealVector#walkInOptimizedOrder(RealVectorPreservingVisitor)}
    054         * or
    055         * {@link RealVector#walkInOptimizedOrder(RealVectorPreservingVisitor, int, int)}
    056         */
    057        double end();
    058    }