Class MinimalList

  • public class MinimalList
    extends Object
    MinimalList provides a set of static methods to dynamically choose the most efficient List implementation. The implementation of List is changed as needed. MinimalList is most suited for building list-based data structures that use less heap space than a pure ArrayList-based solution.

    size=0: Collections.emptyList()
    size=1: Collections.singletonList(java.lang.Object)
    size=2: ArrayList

    AO Industries, Inc.
    • Method Detail

      • emptyList

        public static <E> List<E> emptyList()
        Gets the empty list representation.
      • add

        public static <E> List<E> add​(List<E> list,
                                      E elem)
        Adds a new element to a list, returning the (possibly new) list.
      • copy

        public static <E> List<E> copy​(List<E> list)
        Performs a shallow copy of a list. The list is assumed to have been created by MinimalList and to be used through MinimalList.
      • unmodifiable

        public static <E> List<E> unmodifiable​(List<E> list)
        Gets an unmodifiable wrapper around this list. May or may not wrap this list itself.