Package org.jibx.util
Class LazyList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList
-
- org.jibx.util.LazyList
-
- All Implemented Interfaces:
Iterable,Collection,List
public class LazyList extends AbstractList
List implementation with lazy array construction and modification tracking. The lazy array construction is a minor optimization, to save the added overhead of a backing array for lists which are frequently empty. The modification tracking feature supports filtered list construction with result caching.- Author:
- Dennis M. Sosnoski
-
-
Field Summary
Fields Modifier and Type Field Description static IteratorEMPTY_ITERATORSingleton iterator for empty collection.static LazyListEMPTY_LISTUnmodifiable empty list instance.-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description LazyList()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, Object element)voidcompact()Compact the list, removing anynullvalues.Objectget(int index)intgetModCount()Get modify counter.Iteratoriterator()Objectremove(int index)voidremove(int from, int to)Remove range of values.protected voidremoveRange(int from, int to)Objectset(int index, Object element)intsize()-
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
-
-
-
Method Detail
-
get
public Object get(int index)
- Specified by:
getin interfaceList- Specified by:
getin classAbstractList
-
size
public int size()
- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceList- Specified by:
sizein classAbstractCollection
-
add
public void add(int index, Object element)- Specified by:
addin interfaceList- Overrides:
addin classAbstractList
-
iterator
public Iterator iterator()
- Specified by:
iteratorin interfaceCollection- Specified by:
iteratorin interfaceIterable- Specified by:
iteratorin interfaceList- Overrides:
iteratorin classAbstractList
-
remove
public Object remove(int index)
- Specified by:
removein interfaceList- Overrides:
removein classAbstractList
-
set
public Object set(int index, Object element)
- Specified by:
setin interfaceList- Overrides:
setin classAbstractList
-
removeRange
protected void removeRange(int from, int to)- Overrides:
removeRangein classAbstractList
-
getModCount
public int getModCount()
Get modify counter. This supports tracking changes to determine when cached filters need to be updated.- Returns:
- count
-
remove
public void remove(int from, int to)Remove range of values. This is just a public version of the protected base class methodremoveRange(int, int)- Parameters:
from- Fromto- To
-
compact
public void compact()
Compact the list, removing anynullvalues.
-
-