Package com.xceptance.xlt.api.util
Class SimpleArrayList<T>
- java.lang.Object
-
- com.xceptance.xlt.api.util.SimpleArrayList<T>
-
- All Implemented Interfaces:
java.lang.Iterable<T>,java.util.Collection<T>,java.util.List<T>
public class SimpleArrayList<T> extends java.lang.Object implements java.util.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
-
-
Constructor Summary
Constructors Constructor Description 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, java.util.Collection<? extends T> c)booleanaddAll(java.util.Collection<? extends T> c)voidclear()Clears the list by setting the size to zero.booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection<?> c)Tget(int index)Return an element at index.intindexOf(java.lang.Object o)booleanisEmpty()java.util.Iterator<T>iterator()intlastIndexOf(java.lang.Object o)java.util.ListIterator<T>listIterator()java.util.ListIterator<T>listIterator(int index)java.util.List<java.util.List<T>>partition(int count)Returns view partitions on the underlying list.Tremove(int index)booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> c)booleanretainAll(java.util.Collection<?> c)Tset(int index, T element)intsize()Returns the size of this listjava.util.List<T>subList(int fromIndex, int toIndex)java.lang.Object[]toArray()Creates an array of the elements.<T> T[]toArray(T[] array)Creates an array of the elements.
-
-
-
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.- Specified by:
getin interfacejava.util.List<T>- Parameters:
index- the position- Returns:
- the element at this position
-
size
public int size()
Returns the size of this list
-
toArray
public java.lang.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 java.util.List<java.util.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(java.lang.Object o)
-
iterator
public java.util.Iterator<T> iterator()
-
remove
public boolean remove(java.lang.Object o)
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
-
addAll
public boolean addAll(java.util.Collection<? extends T> c)
-
addAll
public boolean addAll(int index, java.util.Collection<? extends T> c)- Specified by:
addAllin interfacejava.util.List<T>
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOfin interfacejava.util.List<T>
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOfin interfacejava.util.List<T>
-
listIterator
public java.util.ListIterator<T> listIterator()
- Specified by:
listIteratorin interfacejava.util.List<T>
-
listIterator
public java.util.ListIterator<T> listIterator(int index)
- Specified by:
listIteratorin interfacejava.util.List<T>
-
-