Module md.grammar

Class ListUtil


  • public final class ListUtil
    extends Object
    • Constructor Detail

      • ListUtil

        public ListUtil()
    • Method Detail

      • 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
      • append

        public static <T> void append​(List<T> dest,
                                      List<T> source,
                                      int from,
                                      int toExclusive)
      • insert

        public static <T> void insert​(List<T> dest,
                                      int insertPos,
                                      List<T> source,
                                      int from,
                                      int toExclusive)