public void pollNToList ( int n , List < T > retList ) { if ( n >= size ) { // if we need to remove all elements then do fast polling pollAllToList ( retList ) ; } while ( n -- > 0 && head != null ) { T curr = head . element ; this . removeElem ( curr ) ; retList . add ( curr ) ; } shrinkIfNecessary ( ) ; }
Remove and return first n elements on the linked list of all elements . Put elements into the given list .