Class ExternalSetCache<T>
- java.lang.Object
-
- it.unive.lisa.util.collections.externalSet.ExternalSetCache<T>
-
- Type Parameters:
T- the type of elements that this cache stores
public class ExternalSetCache<T> extends java.lang.ObjectA cache for creatingExternalSets of the elements contained in this cache.
-
-
Constructor Summary
Constructors Constructor Description ExternalSetCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Cleans the cache, removing all elements.protected Tget(int pos)Yields thepos-th element of this cache.protected intindexOf(T e)Yields the index where the given element is stored in this cache.protected intindexOfOrAdd(T e)Yields the index where the given element is stored in this cache.ExternalSet<T>mkEmptySet()Builds an emptyExternalSetthat uses this cache.ExternalSet<T>mkSet(java.lang.Iterable<T> iterable)Builds anExternalSetthat uses this cache and contains the elements of the given iterable.ExternalSet<T>mkSingletonSet(T element)Builds anExternalSetthat uses this cache and contains only the given element.ExternalSet<T>mkUniversalSet()Builds anExternalSetthat uses this cache and contains all of its elements.intsize()Yields the total number of elements stored in this cache.java.lang.StringtoString()
-
-
-
Method Detail
-
mkEmptySet
public ExternalSet<T> mkEmptySet()
Builds an emptyExternalSetthat uses this cache.- Returns:
- the empty set
-
mkSet
public ExternalSet<T> mkSet(java.lang.Iterable<T> iterable)
Builds anExternalSetthat uses this cache and contains the elements of the given iterable.- Parameters:
iterable- the iterable- Returns:
- the set
-
mkSingletonSet
public ExternalSet<T> mkSingletonSet(T element)
Builds anExternalSetthat uses this cache and contains only the given element.- Parameters:
element- the element- Returns:
- the set
-
mkUniversalSet
public ExternalSet<T> mkUniversalSet()
Builds anExternalSetthat uses this cache and contains all of its elements. The returned set will stay up to date with this cache.- Returns:
- the set
-
indexOf
protected final int indexOf(T e)
Yields the index where the given element is stored in this cache.- Parameters:
e- the element- Returns:
- the index of
e, or-1
-
indexOfOrAdd
protected final int indexOfOrAdd(T e)
Yields the index where the given element is stored in this cache. If the element is not currently in this cache, it is added.- Parameters:
e- the element- Returns:
- the index of
e
-
get
protected final T get(int pos)
Yields thepos-th element of this cache.- Parameters:
pos- the position- Returns:
- the element
-
clear
public final void clear()
Cleans the cache, removing all elements.
-
size
public final int size()
Yields the total number of elements stored in this cache.- Returns:
- the number of elements
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-