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 do not alter the entries of the vector being 022 * visited. 023 * 024 * @since 3.1 025 */ 026public interface RealVectorPreservingVisitor { 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 */ 043 void visit(int index, double value); 044 045 /** 046 * End visiting a vector. This method is called once, after all entries of 047 * the vector have been visited. 048 * 049 * @return the value returned by 050 * {@link RealVector#walkInDefaultOrder(RealVectorPreservingVisitor)}, 051 * {@link RealVector#walkInDefaultOrder(RealVectorPreservingVisitor, int, int)}, 052 * {@link RealVector#walkInOptimizedOrder(RealVectorPreservingVisitor)} 053 * or 054 * {@link RealVector#walkInOptimizedOrder(RealVectorPreservingVisitor, int, int)} 055 */ 056 double end(); 057}