protected int binarySearchHashCode ( int elemHash ) { int left = 0 ; int right = size ( ) - 1 ; while ( left <= right ) { int mid = ( left + right ) >> 1 ; int midHash = get ( mid ) . hashCode ( ) ; if ( elemHash == midHash ) return mid ; if ( elemHash < midHash ) right = mid - 1 ; else left = mid + 1 ; } return - ( left + 1 ) ; }
Performs a binary search on hashCode values only . It will return any matching element not necessarily the first or the last .