Package com.strobel.collections
Class SmartList<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- com.strobel.collections.SmartList<E>
-
- All Implemented Interfaces:
java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.List<E>
public class SmartList<E> extends java.util.AbstractList<E>
AList
that is optimised for the sizes of 0 and 1, in which cases no array is allocated.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
SmartList.SingletonIterator
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, E e)
boolean
add(E e)
void
clear()
E
get(int index)
int
getModificationCount()
java.util.Iterator<E>
iterator()
E
remove(int index)
E
set(int index, E element)
int
size()
void
sort(java.util.Comparator<? super E> comparator)
<T> T[]
toArray(T[] a)
void
trimToSize()
Trims the capacity of this list to be the list's current size.-
Methods inherited from class java.util.AbstractList
addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, removeRange, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toString
-
-
-
-
Method Detail
-
get
public E get(int index)
-
add
public boolean add(E e)
-
add
public void add(int index, E e)
-
size
public int size()
-
clear
public void clear()
-
remove
public E remove(int index)
-
getModificationCount
public int getModificationCount()
-
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.
-
-