Class SplitList<T>

  • Type Parameters:
    T - the type of objects in the lists

    public class SplitList<T>
    extends Object
    Provides a way to split a list into two parts around a given position.
    • Constructor Detail

      • SplitList

        public SplitList​(List<T> first,
                         List<T> second)
        Creates a new split list.
        Parameters:
        first - the first part of the list
        second - the second part of the list
    • Method Detail

      • getFirstPart

        public List<T> getFirstPart()
        Gets the first part of the original list.
        Returns:
        returns the first part
      • getSecondPart

        public List<T> getSecondPart()
        Gets the second part of the original list.
        Returns:
        returns the second part
      • split

        public static <T> SplitList<T> split​(List<T> in,
                                             int pos)
        Splits the list into two parts at the specified position. The returned object is backed by the original list.
        Type Parameters:
        T - The type of list
        Parameters:
        in - the original list
        pos - the position to split (must be >=0 && <=size())
        Returns:
        returns the split list