类 SmartList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
cn.taketoday.util.SmartList<E>
- 所有已实现的接口:
ArraySizeTrimmer,Iterable<E>,Collection<E>,List<E>,RandomAccess
A List which is optimised for the sizes of 0 and 1,
in which cases it would not allocate array at all.
The tradeoff is the following: this list is slower than
ArrayList but occupies less memory in case of 0 or 1 elements.
Please use it only if your code contains many near-empty lists outside the very hot loops.- 从以下版本开始:
- 4.0 2022/9/4 19:53
- 作者:
- Harry Yang
-
字段概要
字段从类继承的字段 java.util.AbstractList
modCount -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidbooleanprivate E[]asArray()private Eprivate static voidcheckOutOfBounds(int index, int size, boolean inclusive) voidclear()private booleancompareOneByOne(int size, List<?> that) booleanbooleanprivate booleanequalsWithArrayList(ArrayList<?> that) private booleanequalsWithSmartList(SmartList<?> that) voidget(int index) intintstatic <T> intindexOf(T[] src, T obj, int start, int end) iterator()static <T> T[]realloc(T[] array, int newSize, IntFunction<T[]> factory) remove(int index) private E[]resizeIfNecessary(int size) intsize()voidsort(Comparator<? super E> comparator) <T> T[]toArray(T[] a) toString()voidTrims the capacity of this list to be the list's current size.从类继承的方法 java.util.AbstractList
addAll, hashCode, lastIndexOf, listIterator, listIterator, removeRange, subList从类继承的方法 java.util.AbstractCollection
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray从接口继承的方法 java.util.Collection
parallelStream, removeIf, stream, toArray从接口继承的方法 java.util.List
addAll, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, spliterator, toArray
-
字段详细资料
-
size
private int size -
element
-
-
构造器详细资料
-
SmartList
public SmartList() -
SmartList
-
SmartList
-
SmartList
-
-
方法详细资料
-
get
-
checkOutOfBounds
private static void checkOutOfBounds(int index, int size, boolean inclusive) -
add
- 指定者:
add在接口中Collection<E>- 指定者:
add在接口中List<E>- 覆盖:
add在类中AbstractList<E>
-
resizeIfNecessary
-
realloc
-
add
-
size
public int size()- 指定者:
size在接口中Collection<E>- 指定者:
size在接口中List<E>- 指定者:
size在类中AbstractCollection<E>
-
clear
public void clear()- 指定者:
clear在接口中Collection<E>- 指定者:
clear在接口中List<E>- 覆盖:
clear在类中AbstractList<E>
-
set
-
asElement
-
asArray
-
remove
-
iterator
-
sort
-
getModificationCount
public int getModificationCount() -
toArray
public <T> T[] toArray(T[] a) - 指定者:
toArray在接口中Collection<E>- 指定者:
toArray在接口中List<E>- 覆盖:
toArray在类中AbstractCollection<E>
-
trimToSize
public void trimToSize()Trims the capacity of this list to be the list's current size. An application can use this operation to minimize the storage of a list instance.- 指定者:
trimToSize在接口中ArraySizeTrimmer
-
indexOf
-
indexOf
-
contains
- 指定者:
contains在接口中Collection<E>- 指定者:
contains在接口中List<E>- 覆盖:
contains在类中AbstractCollection<E>
-
equals
- 指定者:
equals在接口中Collection<E>- 指定者:
equals在接口中List<E>- 覆盖:
equals在类中AbstractList<E>
-
equalsWithSmartList
-
equalsWithArrayList
-
compareOneByOne
-
forEach
-
toString
- 覆盖:
toString在类中AbstractCollection<E>
-