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>,SequencedCollection<T>
- Direct Known Subclasses:
SimpleArrayList.Partition
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
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new list with a default capacity.SimpleArrayList(int capacity) Create a new list with a default capacity.SimpleArrayList(SimpleArrayList<T> list) Creates a new list wrapper from an existing one. -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanAdd 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.booleanbooleancontainsAll(Collection<?> c) get(int index) Return an element at index.intbooleanisEmpty()iterator()intlistIterator(int index) partition(int count) Returns view partitions on the underlying list.remove(int index) Removes the data at index and shifts all data right of itbooleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()Returns the size of this listsubList(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, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Field Details
-
data
-
size
private int size
-
-
Constructor Details
-
SimpleArrayList
SimpleArrayList(SimpleArrayList<T> list) Creates a new list wrapper from an existing one. This is not copying anything rather referencing it. Make sure that you understand that!- Parameters:
list-
-
SimpleArrayList
public SimpleArrayList(int capacity) Create a new list with a default capacity.- Parameters:
capacity- the capacity
-
SimpleArrayList
public SimpleArrayList()Create a new list with a default capacity.
-
-
Method Details
-
add
Add an element to the end of the list -
add
-
get
Return an element at index. No range checks at all. -
size
public int size()Returns the size of this list -
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
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
-
iterator
-
remove
-
containsAll
- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceList<T>
-
addAll
-
addAll
-
removeAll
-
retainAll
-
set
-
remove
Removes the data at index and shifts all data right of it -
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<T>
-
listIterator
- Specified by:
listIteratorin interfaceList<T>
-
listIterator
- Specified by:
listIteratorin interfaceList<T>
-
subList
-