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 void
add(int index, T element)
boolean
add(T element)
Add an element to the end of the listboolean
addAll(int index, java.util.Collection<? extends T> c)
boolean
addAll(java.util.Collection<? extends T> c)
void
clear()
Clears the list by setting the size to zero.boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection<?> c)
T
get(int index)
Return an element at index.int
indexOf(java.lang.Object o)
boolean
isEmpty()
java.util.Iterator<T>
iterator()
int
lastIndexOf(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.T
remove(int index)
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
boolean
retainAll(java.util.Collection<?> c)
T
set(int index, T element)
int
size()
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:
get
in 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:
addAll
in 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:
indexOf
in interfacejava.util.List<T>
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOf
in interfacejava.util.List<T>
-
listIterator
public java.util.ListIterator<T> listIterator()
- Specified by:
listIterator
in interfacejava.util.List<T>
-
listIterator
public java.util.ListIterator<T> listIterator(int index)
- Specified by:
listIterator
in interfacejava.util.List<T>
-
-