Class ArrayBackedCollection<T>
java.lang.Object
com.espertech.esper.common.internal.collection.ArrayBackedCollection<T>
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
A fast collection backed by an array with severe limitations. Allows direct access to the backing array
- this must be used with care as old elements could be in the array and the array is only valid until
the number of elements indicated by size.
Implements only the add, size and clear methods of the collection interface.
When running out of space for the underlying array, allocates a new array of double the size of the current array.
Not synchronized and not thread-safe.
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
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
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
ArrayBackedCollection
public ArrayBackedCollection(int currentSize) Ctor.- Parameters:
currentSize
- is the initial size of the backing array.
-
-
Method Details
-
add
- Specified by:
add
in interfaceCollection<T>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<T>
-
size
public int size()- Specified by:
size
in interfaceCollection<T>
-
getArray
Returns the backing object array, valid until the current size.Applications must ensure to not read past current size as old elements can be encountered.
- Returns:
- backing array
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<T>
-
contains
- Specified by:
contains
in interfaceCollection<T>
-
iterator
-
toArray
- Specified by:
toArray
in interfaceCollection<T>
-
remove
- Specified by:
remove
in interfaceCollection<T>
-
addAll
- Specified by:
addAll
in interfaceCollection<T>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<T>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<T>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<T>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<T>
-