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 */ 017package org.apache.commons.math3.linear; 018 019/** 020 * This interface defines a visitor for the entries of a vector. Visitors 021 * implementing this interface may alter the entries of the vector being 022 * visited. 023 * 024 * @since 3.1 025 */ 026public interface RealVectorChangingVisitor { 027 /** 028 * Start visiting a vector. This method is called once, before any entry 029 * of the vector is visited. 030 * 031 * @param dimension the size of the vector 032 * @param start the index of the first entry to be visited 033 * @param end the index of the last entry to be visited (inclusive) 034 */ 035 void start(int dimension, int start, int end); 036 037 /** 038 * Visit one entry of the vector. 039 * 040 * @param index the index of the entry being visited 041 * @param value the value of the entry being visited 042 * @return the new value of the entry being visited 043 */ 044 double 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(RealVectorChangingVisitor)}, 052 * {@link RealVector#walkInDefaultOrder(RealVectorChangingVisitor, int, int)}, 053 * {@link RealVector#walkInOptimizedOrder(RealVectorChangingVisitor)} 054 * or 055 * {@link RealVector#walkInOptimizedOrder(RealVectorChangingVisitor, int, int)} 056 */ 057 double end(); 058}