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 019import org.apache.commons.math3.FieldElement; 020 021/** 022 * This interface defines a visitor for the entries of a vector. Visitors 023 * implementing this interface do not alter the entries of the vector being 024 * visited. 025 * 026 * @param <T> the type of the field elements 027 * @since 3.3 028 */ 029public interface FieldVectorPreservingVisitor<T extends FieldElement<?>> { 030 /** 031 * Start visiting a vector. This method is called once, before any entry 032 * of the vector is visited. 033 * 034 * @param dimension the size of the vector 035 * @param start the index of the first entry to be visited 036 * @param end the index of the last entry to be visited (inclusive) 037 */ 038 void start(int dimension, int start, int end); 039 040 /** 041 * Visit one entry of the vector. 042 * 043 * @param index the index of the entry being visited 044 * @param value the value of the entry being visited 045 */ 046 void visit(int index, T value); 047 048 /** 049 * End visiting a vector. This method is called once, after all entries of 050 * the vector have been visited. 051 * 052 * @return the value returned after visiting all entries 053 */ 054 T end(); 055}