Here you can find the source of findMinimaGreaterOrEqual(final int[] min, final int elt)
private static int findMinimaGreaterOrEqual(final int[] min, final int elt)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { private static int findMinimaGreaterOrEqual(final int[] min, final int elt) { int tempPos = Arrays.binarySearch(min, elt); if (tempPos >= 0) { tempPos = backTrack(min, tempPos); } else {/*from w w w.ja va2 s . co m*/ tempPos = -(tempPos + 1); tempPos = Math.min(min.length - 1, tempPos); } return tempPos; } public static int backTrack(final int[] arr, int pos) { while (pos > 0 && arr[pos - 1] == arr[pos]) { --pos; } return pos; } }