/// <summary> /// Visits (and possibly alters) some entries of this vector in default order /// (increasing index). /// </summary> /// <param name="visitor">visitor to be used to process the entries of this vector</param> /// <param name="start">the index of the first entry to be visited</param> /// <param name="end">the index of the last entry to be visited (inclusive)</param> /// <returns>the value returned by <see cref="FieldVectorChangingVisitor.end()"/> /// at the end of the walk</returns> /// <exception cref="NumberIsTooSmallException"> if <c>end < start</c>.</exception> /// <exception cref="OutOfRangeException"> if the indices are not valid.</exception> public T walkInDefaultOrder(FieldVectorChangingVisitor <T> visitor, int start, int end) { checkIndices(start, end); visitor.start(getDimension(), start, end); for (int i = start; i <= end; i++) { setEntry(i, visitor.visit(i, getEntry(i))); } return(visitor.end()); }
/// <summary> /// Visits (and possibly alters) all entries of this vector in default order /// (increasing index). /// </summary> /// <param name="visitor">the visitor to be used to process and modify the entries /// of this vector</param> /// <returns>the value returned by <see cref="FieldVectorChangingVisitor.end()"/> /// at the end of the walk</returns> public T walkInDefaultOrder(FieldVectorChangingVisitor <T> visitor) { int dim = getDimension(); visitor.start(dim, 0, dim - 1); for (int i = 0; i < dim; i++) { setEntry(i, visitor.visit(i, getEntry(i))); } return(visitor.end()); }
/// <summary> /// Visits (and possibly change) some entries of this vector in optimized /// order. The order in which the entries are visited is selected so as to /// lead to the most efficient implementation; it might depend on the /// concrete implementation of this abstract class. /// </summary> /// <param name="visitor">visitor to be used to process the entries of this vector</param> /// <param name="start">the index of the first entry to be visited</param> /// <param name="end">the index of the last entry to be visited (inclusive)</param> /// <returns>the value returned by <see cref="FieldVectorChangingVisitor.end()"/> /// at the end of the walk</returns> /// <exception cref="NumberIsTooSmallException"> if <c>end < start</c>.</exception> /// <exception cref="OutOfRangeException"> if the indices are not valid.</exception> public T walkInOptimizedOrder(FieldVectorChangingVisitor <T> visitor, int start, int end) { return(walkInDefaultOrder(visitor, start, end)); }
/// <summary> /// Visits (and possibly alters) all entries of this vector in optimized /// order. The order in which the entries are visited is selected so as to /// lead to the most efficient implementation; it might depend on the /// concrete implementation of this abstract class. /// </summary> /// <param name="visitor">the visitor to be used to process the entries of this /// vector</param> /// <returns>the value returned by <see cref="FieldVectorChangingVisitor.end()"/> /// at the end of the walk</returns> public T walkInOptimizedOrder(FieldVectorChangingVisitor <T> visitor) { return(walkInDefaultOrder(visitor)); }