jodd-core/src/main/java/jodd/util/BinarySearch.java
public int find(final E element, int low, int high) {
		while (low <= high) {
			int mid = (low + high) >>> 1;
			int delta = compare(mid, element);

			if (delta < 0) {
				low = mid + 1;
			} else if (delta > 0) {
				high = mid - 1;
			} else {
				return mid;
			}
		}
		// not found
		return -(low + 1);
	}
public int find(final E element, int low, int high) {
		while (low <= high) {
			int mid = (low + high) >>> 1;
			int delta = compare(mid, element);

			if (delta < 0) {
				low = mid + 1;
			} else if (delta > 0) {
				high = mid - 1;
			} else {
				return mid;
			}
		}
		// not found
		return -(low + 1);
	}
public int find ( final E element , int low , int high ) { while ( low <= high ) { int mid = ( low + high ) >>> 1 ; int delta = compare ( mid , element ) ; if ( delta < 0 ) { low = mid + 1 ; } else if ( delta > 0 ) { high = mid - 1 ; } else { return mid ; } } // not found return - ( low + 1 ) ; }
Finds index of given element in inclusive index range. Returns negative
value if element is not found.
Finds index of given element in inclusive index range . Returns negative value if element is not found .