@ Override public int indexOf ( int elem ) { // Find the location to insert the object at int pos = binarySearch ( elem ) ; // Not found if ( pos < 0 ) return - 1 ; // Found one, iterate backwards to the first one while ( pos > 0 && elementData [ pos - 1 ] == elem ) pos -- ; return pos ; }
Searches for the first occurrence of the given value .