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 may 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 FieldVectorChangingVisitor<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     * @return the new value of the entry being visited
046     */
047    T visit(int index, T value);
048
049    /**
050     * End visiting a vector. This method is called once, after all entries of
051     * the vector have been visited.
052     *
053     * @return the value returned after visiting all entries
054     */
055    T end();
056}