merge
public static <T> List<T> merge(List<T> first,
List<T> second)
Merges two lists while preserving order.
Common sequences are identified in two lists and are output in a merged List in same order as
the originals. If a sequence of elements is found in the second List between two common
elements, it is inserted between them in the merged list. If a non-overlapping sequence is
found in the second List it is appended to the merged List. The method is non-destructive of
its arguments.
It is assumed that the common elements of the two lists are in the same order, but they are
allowed to have intervening non-common elements.
The only requirement for element type is that its equals() method is transitive and
consistent, as specified by Object.equals().
- Type Parameters:
T - element type
- Parameters:
first - a sequence of elements
second - a sequence of elements
- Returns:
- a merged list