Package org.htmlunit.cyberneko.util
Class SimpleArrayList<T>
- java.lang.Object
-
- org.htmlunit.cyberneko.util.SimpleArrayList<T>
-
- All Implemented Interfaces:
Iterable<T>,Collection<T>,List<T>
public class SimpleArrayList<T> extends Object implements List<T>
Inexpensive (partial) list implementation. Not fully implemented, just what is needed. As soon as iterators and other things are involved, the memory savings we wanted are gone.Minimal checks for data correctness!! This is tuned for speed not elegance or safety.
- Since:
- 7.0.0
- Author:
- Rene Schwietzke
-
-
Constructor Summary
Constructors Constructor Description SimpleArrayList()Create a new list with a default capacity.SimpleArrayList(int capacity)Create a new list with a default capacity.
-
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 end of the listbooleanaddAll(int index, Collection<? extends T> c)booleanaddAll(Collection<? extends T> c)voidclear()Clears the list by setting the size to zero.booleancontains(Object o)booleancontainsAll(Collection<?> c)Tget(int index)Return an element at index.intindexOf(Object o)booleanisEmpty()Iterator<T>iterator()intlastIndexOf(Object o)ListIterator<T>listIterator()ListIterator<T>listIterator(int index)List<List<T>>partition(int count)Returns view partitions on the underlying list.Tremove(int index)Removes the data at index and shifts all data right of itbooleanremove(Object o)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)Tset(int index, T element)intsize()Returns the size of this listList<T>subList(int fromIndex, int toIndex)Object[]toArray()Creates an array of the elements.<T> T[]toArray(T[] array)Creates an array of the elements.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
equals, hashCode, replaceAll, sort, spliterator
-
-
-
-
Method Detail
-
add
public boolean add(T element)
Add an element to the end of the list
-
get
public T get(int index)
Return an element at index. No range checks at all.
-
size
public int size()
Returns the size of this list
-
toArray
public Object[] toArray()
Creates an array of the elements. This is a copy operation!
-
toArray
public <T> T[] toArray(T[] array)
Creates an array of the elements. This is a copy operation!
-
clear
public void clear()
Clears the list by setting the size to zero. It does not release any elements for performance purposes.
-
partition
public List<List<T>> partition(int count)
Returns view partitions on the underlying list. If the count is larger than size you get back the maximum possible list number with one element each. If count is 0 or smaller, we correct it to 1.- Parameters:
count- how many list do we want- Returns:
- a list of lists
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(Object o)
-
remove
public boolean remove(Object o)
-
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)
-
remove
public T remove(int index)
Removes the data at index and shifts all data right of it
-
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>
-
-