Java Array Min Value minIndexGreaterThan(final double[] array, final double p)

Here you can find the source of minIndexGreaterThan(final double[] array, final double p)

Description

Return the minimal index for which the corresponding array element is greater than a certain threshold.

License

Apache License

Parameter

Parameter Description
array array
p threshold value

Return

minimal index for which array[k] >= p. If no such index exists, returns array.length

Declaration

public static int minIndexGreaterThan(final double[] array, final double p) 

Method Source Code

//package com.java2s;
/**/*from  w  w  w. j  a  v  a2  s  . c  o  m*/
 * Copyright (C) [2013] [The FURTHeR Project]
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License 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.
 */

public class Main {
    /**
     * Return the minimal index for which the corresponding array element is greater than
     * a certain threshold.
     *
     * @param array
     *            array
     * @param p
     *            threshold value
     * @return minimal index for which <code>array[k] >= p</code>. If no such index
     *         exists, returns <code>array.length</code>
     */
    public static int minIndexGreaterThan(final double[] array, final double p) {
        final int size = array.length;
        for (int k = 0; k < size; k++) {
            if (array[k] >= p) {
                return k;
            }
        }
        return size;
    }
}

Related

  1. minIndex(int[] array)
  2. minIndex(int[] from)
  3. minIndex(int[] ints)
  4. minIndex(int[] values)
  5. minIndex(Number[] array)
  6. minInRowIndex(double[][] M, int row)
  7. minInt(int... values)
  8. minkowskiDistance(double[] coord1, double[] coord2)
  9. minLengthCheck(final byte[] buffer, final byte length)