java.lang.Object
com.aoapps.collections.MinimalList
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
Modifier and TypeMethodDescriptionstatic <E> List
<E> Adds a new element to a list, returning the (possibly new) list.static <E> List
<E> Performs a shallow copy of a list.static <E> List
<E> Gets the empty list representation.static <E> E
Deprecated.static <E> List
<E> unmodifiable
(List<E> list) Gets an unmodifiable wrapper around this list.
-
Method Details
-
emptyList
Gets the empty list representation. -
add
Adds a new element to a list, returning the (possibly new) list. -
get
Deprecated.Since empty lists are no longer represented bynull
, invokeList.get(int)
directly now.Gets an element from a list.- Throws:
IndexOutOfBoundsException
-
copy
Performs a shallow copy of a list. The list is assumed to have been created by MinimalList and to be used through MinimalList. -
unmodifiable
Gets an unmodifiable wrapper around this list. May or may not wrap this list itself.
-
null
, invokeList.get(int)
directly now.