@ GuardedBy ( "lock" ) protected boolean _compact ( ) { int new_cap = buffer . length >> 1 ; // needs to be a power of 2 for efficient modulo operation, e.g. for index() // boolean compactable=this.buffer.length > 0 && (size() <= new_cap || (contiguousSpaceAvailable=_contiguousSpaceAvailable(new_cap))); boolean compactable = this . buffer . length > 0 && high - low <= new_cap ; if ( ! compactable ) return false ; // not enough space to shrink the buffer to half its size _copy ( new_cap ) ; return true ; }
Shrinks the array to half of its current size if the current number of elements fit into half of the capacity .