public static < E > int remove ( List < E > list , Comparator < ? super E > comparator , E data ) { assert list != null ; assert comparator != null ; assert data != null ; int first = 0 ; int last = list . size ( ) - 1 ; while ( last >= first ) { final int center = ( first + last ) / 2 ; final E dt = list . get ( center ) ; final int cmpR = comparator . compare ( data , dt ) ; if ( cmpR == 0 ) { list . remove ( center ) ; return center ; } else if ( cmpR < 0 ) { last = center - 1 ; } else { first = center + 1 ; } } return - 1 ; }
Remove the given element from the list using a dichotomic algorithm .