Java Binary Search binarySearch(byte[] a, byte key, int startPos)

Here you can find the source of binarySearch(byte[] a, byte key, int startPos)

Description

binary Search

License

Open Source License

Declaration

public static int binarySearch(byte[] a, byte key, int startPos) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int binarySearch(byte[] a, byte key, int startPos) {
        if (startPos > a.length || startPos < 0) {
            return -1;
        }/*from   w  w w  . j ava2  s  .  c o m*/

        for (int i = startPos; i < a.length; i++) {
            if (a[i] == key) {
                return i;
            }
        }
        return -1;
    }
}

Related

  1. binarySearch(byte[] a, int key)
  2. binarySearch(byte[] readBuffer, int offset, int length, byte value)
  3. binarySearch(char[] arr, int key)
  4. binarySearch(double experience, int min, int max)