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:
Iterable<E>
,Collection<E>
,List<E>
,SequencedCollection<E>
A
List
that is optimised for the sizes of 0 and 1, in which cases no array is allocated.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
Constructors -
Method Summary
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
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addAll, addFirst, addLast, contains, containsAll, getFirst, getLast, isEmpty, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, spliterator, toArray
-
Field Details
-
_data
-
_size
private int _size
-
-
Constructor Details
-
SmartList
public SmartList() -
SmartList
-
SmartList
-
SmartList
-
-
Method Details
-
get
-
add
- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceList<E>
- Overrides:
add
in classAbstractList<E>
-
add
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceList<E>
- Specified by:
size
in classAbstractCollection<E>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceList<E>
- Overrides:
clear
in classAbstractList<E>
-
set
-
remove
-
iterator
-
sort
-
getModificationCount
public int getModificationCount() -
toArray
- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceList<E>
- Overrides:
toArray
in classAbstractCollection<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.
-