private V binarySearch ( final K iKey ) { int low = 0 ; int high = getSize ( ) - 1 ; int mid = 0 ; while ( low <= high ) { mid = ( low + high ) >>> 1 ; Object midVal = getKeyAt ( mid ) ; if ( tree . comparator != null ) tree . pageItemComparator = tree . comparator . compare ( ( K ) midVal , iKey ) ; else tree . pageItemComparator = ( ( Comparable < ? super K > ) midVal ) . compareTo ( iKey ) ; if ( tree . pageItemComparator == 0 ) { // FOUND: SET THE INDEX AND RETURN THE NODE tree . pageItemFound = true ; tree . pageIndex = mid ; return getValueAt ( tree . pageIndex ) ; } if ( low == high ) break ; if ( tree . pageItemComparator < 0 ) low = mid + 1 ; else high = mid ; } tree . pageIndex = mid ; return null ; }
Binary search inside the node