- java.lang.Object
-
- com.aoapps.collections.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- Author:
- AO Industries, Inc.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <E> List<E>add(List<E> list, E elem)Adds a new element to a list, returning the (possibly new) list.static <E> List<E>copy(List<E> list)Performs a shallow copy of a list.static <E> List<E>emptyList()Gets the empty list representation.static <E> Eget(List<E> list, int index)Deprecated.Since empty lists are no longer represented bynull, invokeList.get(int)directly now.static <E> List<E>unmodifiable(List<E> list)Gets an unmodifiable wrapper around this list.
-
-
-
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.
-
get
@Deprecated public static <E> E get(List<E> list, int index) throws IndexOutOfBoundsException
Deprecated.Since empty lists are no longer represented bynull, invokeList.get(int)directly now.Gets an element from a list.- Throws:
IndexOutOfBoundsException
-
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.
-
-