Here you can find the source of minIndexGreaterThan(final double[] array, final double p)
Parameter | Description |
---|---|
array | array |
p | threshold value |
array[k] >= p
. If no such index exists, returns array.length
public static int minIndexGreaterThan(final double[] array, final double p)
//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; } }