Java Array Equal findMinimaGreaterOrEqual(final int[] min, final int elt)

Here you can find the source of findMinimaGreaterOrEqual(final int[] min, final int elt)

Description

find Minima Greater Or Equal

License

Open Source License

Declaration

private static int findMinimaGreaterOrEqual(final int[] min, final int elt) 

Method Source Code

//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;
    }
}

Related

  1. equalsAny(T element, T[] array)
  2. equalsIgnoreSequence(final T[] array1, final T[] array2)
  3. equalsIgnoreSequence(Object[] array1, Object[] array2)
  4. equalsToElement(final Object[] arr, final Object obj)
  5. equalStringArrays(String[] expected, String[] actual)
  6. getClosestIndexEqualToOrLargerThanGivenCoordinate(double[] coordinates, double coordinate)
  7. isEquals(byte[] id1, byte[] id2)
  8. isEquals(char[] o1, char[] o2)
  9. isEquals(Object firstArray, Object secondArray)