Java Array Shift shift(final double[] values, final double constant)

Here you can find the source of shift(final double[] values, final double constant)

Description

Shifts all the elements of values by constant.

License

Open Source License

Parameter

Parameter Description
values a parameter
constant a parameter

Return

Newly allocated array whose values are values[i]+constant Side Effects: Allocation of new array

Declaration

public static final double[] shift(final double[] values, final double constant) 

Method Source Code

//package com.java2s;
/*//from   w  w w.  j a  va  2 s  .c o  m
 * ====================================================
 * Copyright (C) 2013 by Idylwood Technologies, LLC. All rights reserved.
 *
 * Developed at Idylwood Technologies, LLC.
 * Permission to use, copy, modify, and distribute this
 * software is freely granted, provided that this notice
 * is preserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * The License should have been distributed to you with the source tree.
 * If not, it can be found at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author: Charles Cooper
 * Date: 2013
 * ====================================================
 */

public class Main {
    /**
     * Shifts all the elements of <code>values</code> by <code>constant</code>.
     * @param values
     * @param constant
     * @return Newly allocated array whose values are values[i]+constant
     * Side Effects: Allocation of new array
     */
    public static final double[] shift(final double[] values, final double constant) {
        final double ret[] = new double[values.length];
        for (int i = values.length; i-- != 0;)
            ret[i] = values[i] + constant;
        return ret;
    }
}

Related

  1. arrayShift(Object[] input, int shift)
  2. arrayShiftArgs(int[] array, int a)
  3. shift(double[] a, int shift, double insert)
  4. shift(double[] x, int N)
  5. shift(final byte[] input, final int amount)
  6. shift(final Object[] array, int offset)
  7. Shift(int[] in, int amt, int spare)
  8. shift(int[] v, int n)
  9. shift(int[][] array, boolean inverse)