public boolean put ( T t ) { if ( initial ) { if ( size == data . length ) { if ( size < limit * 2 ) { @ SuppressWarnings ( "unchecked" ) T [ ] newData = ( T [ ] ) new Object [ Math . min ( limit , size ) * 2 ] ; System . arraycopy ( data , 0 , newData , 0 , size ) ; data = newData ; } else { Arrays . sort ( data , comparator ) ; initial = false ; size = limit ; } put ( t ) ; } else { data [ size ++ ] = t ; } return true ; } if ( size == data . length ) { sortTail ( ) ; } if ( comparator . compare ( t , data [ limit - 1 ] ) < 0 ) { data [ size ++ ] = t ; return true ; } return false ; }
Accumulate new element