Class CacheImpl<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<T>
org.aksw.commons.collections.cache.CacheImpl<T>
- Type Parameters:
T-
- All Implemented Interfaces:
AutoCloseable,Iterable<T>,Collection<T>,List<T>,Cache<T>
- Direct Known Subclasses:
StreamBackedList
An iterable that caches (possibly computed) items returned from an underlying iterator, such that
subsequent iterations run from the cache.
Useful for constructing cartesian products on-demand
- Author:
- raven
-
Field Summary
FieldsFields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidclose()get(int index) A call to get blocks until the cache is completeintSize returns the current number of items in the cachegetData()booleanbooleaniterator()voidvoidsetAbandoned(boolean isAbandoned) voidvoidsetComplete(boolean status) intsize()Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, sort, spliterator, subList, toArray, toArray
-
Field Details
-
data
-
-
Constructor Details
-
CacheImpl
-
-
Method Details
-
getData
-
isComplete
public boolean isComplete()- Specified by:
isCompletein interfaceCache<T>
-
setComplete
public void setComplete(boolean status) -
isAbandoned
public boolean isAbandoned()- Specified by:
isAbandonedin interfaceCache<T>
-
setAbandoned
public void setAbandoned(boolean isAbandoned) -
add
- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceList<T>- Overrides:
addin classAbstractList<T>
-
iterator
-
size
public int size()- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceList<T>- Specified by:
sizein classAbstractCollection<T>
-
getCurrentSize
public int getCurrentSize()Size returns the current number of items in the cache- Specified by:
getCurrentSizein interfaceCache<T>
-
setComplete
public void setComplete()- Specified by:
setCompletein interfaceCache<T>
-
setAbandoned
public void setAbandoned()- Specified by:
setAbandonedin interfaceCache<T>
-
get
A call to get blocks until the cache is complete -
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-