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 may alter the entries of the vector being 022 * visited. 023 * 024 * @version $Id: RealVectorChangingVisitor.java 1416643 2012-12-03 19:37:14Z tn $ 025 * @since 3.1 026 */ 027 public interface RealVectorChangingVisitor { 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 * @return the new value of the entry being visited 044 */ 045 double visit(int index, double value); 046 047 /** 048 * End visiting a vector. This method is called once, after all entries of 049 * the vector have been visited. 050 * 051 * @return the value returned by 052 * {@link RealVector#walkInDefaultOrder(RealVectorChangingVisitor)}, 053 * {@link RealVector#walkInDefaultOrder(RealVectorChangingVisitor, int, int)}, 054 * {@link RealVector#walkInOptimizedOrder(RealVectorChangingVisitor)} 055 * or 056 * {@link RealVector#walkInOptimizedOrder(RealVectorChangingVisitor, int, int)} 057 */ 058 double end(); 059 }