@ SuppressWarnings ( "unchecked" ) public static < T > T [ ] reverse ( T [ ] self , boolean mutate ) { if ( ! mutate ) { return ( T [ ] ) toList ( new ReverseListIterator < T > ( Arrays . asList ( self ) ) ) . toArray ( ) ; } List < T > items = Arrays . asList ( self ) ; Collections . reverse ( items ) ; System . arraycopy ( items . toArray ( ) , 0 , self , 0 , items . size ( ) ) ; return self ; }
Reverse the items in an array . If mutate is true the original array is modified in place and returned . Otherwise a new array containing the reversed items is produced .