static < I , S extends Iterable < I > > Object [ ] addTerminalToSequence ( S sequence , SequenceTerminal < S > terminatingObject ) { ArrayList < Object > list = new ArrayList <> ( ) ; for ( I item : sequence ) list . ( item ) ; Object [ ] newSequence = new Object [ list . size ( ) + 1 ] ; int i = 0 ; for ( ; i < list . size ( ) ; i ++ ) newSequence [ i ] = list . get ( i ) ; newSequence [ i ] = terminatingObject ; return newSequence ; }
Appends a SequenceTerminal element to a supplied array .