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.Object
A cache for creatingExternalSet
s 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 void
clear()
Cleans the cache, removing all elements.protected T
get(int pos)
Yields thepos
-th element of this cache.protected int
indexOf(T e)
Yields the index where the given element is stored in this cache.protected int
indexOfOrAdd(T e)
Yields the index where the given element is stored in this cache.ExternalSet<T>
mkEmptySet()
Builds an emptyExternalSet
that uses this cache.ExternalSet<T>
mkSet(java.lang.Iterable<T> iterable)
Builds anExternalSet
that uses this cache and contains the elements of the given iterable.ExternalSet<T>
mkSingletonSet(T element)
Builds anExternalSet
that uses this cache and contains only the given element.ExternalSet<T>
mkUniversalSet()
Builds anExternalSet
that uses this cache and contains all of its elements.int
size()
Yields the total number of elements stored in this cache.java.lang.String
toString()
-
-
-
Method Detail
-
mkEmptySet
public ExternalSet<T> mkEmptySet()
Builds an emptyExternalSet
that uses this cache.- Returns:
- the empty set
-
mkSet
public ExternalSet<T> mkSet(java.lang.Iterable<T> iterable)
Builds anExternalSet
that 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 anExternalSet
that uses this cache and contains only the given element.- Parameters:
element
- the element- Returns:
- the set
-
mkUniversalSet
public ExternalSet<T> mkUniversalSet()
Builds anExternalSet
that 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:
toString
in classjava.lang.Object
-
-