Class FastList<T>
- java.lang.Object
-
- org.xipki.pkcs11.wrapper.concurrent.FastList<T>
-
- All Implemented Interfaces:
Serializable,Iterable<T>,Collection<T>,List<T>,RandomAccess
public final class FastList<T> extends Object implements List<T>, RandomAccess, Serializable
Fast list without range checking.- Author:
- Brett Wooldridge
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, T element)booleanadd(T element)Add an element to the tail of the FastList.booleanaddAll(int index, Collection<? extends T> c)booleanaddAll(Collection<? extends T> c)voidclear()Clear the FastList.Objectclone()booleancontains(Object o)booleancontainsAll(Collection<?> c)voidforEach(Consumer<? super T> action)Tget(int index)Get the element at the specified index.intindexOf(Object o)booleanisEmpty()Iterator<T>iterator()intlastIndexOf(Object o)ListIterator<T>listIterator()ListIterator<T>listIterator(int index)Tremove(int index)booleanremove(Object element)This remove method is most efficient when the element being removed is the last element.booleanremoveAll(Collection<?> c)booleanremoveIf(Predicate<? super T> filter)TremoveLast()Remove the last element from the list.voidreplaceAll(UnaryOperator<T> operator)booleanretainAll(Collection<?> c)Tset(int index, T element)intsize()Get the current number of elements in the FastList.voidsort(Comparator<? super T> c)Spliterator<T>spliterator()List<T>subList(int fromIndex, int toIndex)Object[]toArray()<E> E[]toArray(E[] a)-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
-
-
-
Constructor Detail
-
FastList
public FastList(Class<?> clazz)
Construct a FastList with a default size of 32.- Parameters:
clazz- the Class stored in the collection
-
FastList
public FastList(Class<?> clazz, int capacity)
Construct a FastList with a specified size.- Parameters:
clazz- the Class stored in the collectioncapacity- the initial size of the FastList
-
-
Method Detail
-
add
public boolean add(T element)
Add an element to the tail of the FastList.
-
get
public T get(int index)
Get the element at the specified index.
-
removeLast
public T removeLast()
Remove the last element from the list. No bound check is performed, so if this method is called on an empty list and ArrayIndexOutOfBounds exception will be thrown.- Returns:
- the last element of the list
-
remove
public boolean remove(Object element)
This remove method is most efficient when the element being removed is the last element. Equality is identity based, not equals() based. Only the first matching element is removed.
-
clear
public void clear()
Clear the FastList.
-
size
public int size()
Get the current number of elements in the FastList.
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(Object o)
-
toArray
public Object[] toArray()
-
toArray
public <E> E[] toArray(E[] a)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceList<T>
-
addAll
public boolean addAll(Collection<? extends T> c)
-
addAll
public boolean addAll(int index, Collection<? extends T> c)
-
removeAll
public boolean removeAll(Collection<?> c)
-
retainAll
public boolean retainAll(Collection<?> c)
-
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOfin interfaceList<T>
-
listIterator
public ListIterator<T> listIterator()
- Specified by:
listIteratorin interfaceList<T>
-
listIterator
public ListIterator<T> listIterator(int index)
- Specified by:
listIteratorin interfaceList<T>
-
spliterator
public Spliterator<T> spliterator()
- Specified by:
spliteratorin interfaceCollection<T>- Specified by:
spliteratorin interfaceIterable<T>- Specified by:
spliteratorin interfaceList<T>
-
removeIf
public boolean removeIf(Predicate<? super T> filter)
- Specified by:
removeIfin interfaceCollection<T>
-
replaceAll
public void replaceAll(UnaryOperator<T> operator)
- Specified by:
replaceAllin interfaceList<T>
-
sort
public void sort(Comparator<? super T> c)
-
-