Class ExternalSetCache<T>

  • Type Parameters:
    T - the type of elements that this cache stores

    public class ExternalSetCache<T>
    extends java.lang.Object
    A cache for creating ExternalSets of the elements contained in this cache.
    • 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 the pos-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 empty ExternalSet that uses this cache.
      ExternalSet<T> mkSet​(java.lang.Iterable<T> iterable)
      Builds an ExternalSet that uses this cache and contains the elements of the given iterable.
      ExternalSet<T> mkSingletonSet​(T element)
      Builds an ExternalSet that uses this cache and contains only the given element.
      ExternalSet<T> mkUniversalSet()
      Builds an ExternalSet 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()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ExternalSetCache

        public ExternalSetCache()
    • Method Detail

      • mkEmptySet

        public ExternalSet<T> mkEmptySet()
        Builds an empty ExternalSet that uses this cache.
        Returns:
        the empty set
      • mkSet

        public ExternalSet<T> mkSet​(java.lang.Iterable<T> iterable)
        Builds an ExternalSet 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 an ExternalSet that uses this cache and contains only the given element.
        Parameters:
        element - the element
        Returns:
        the set
      • mkUniversalSet

        public ExternalSet<T> mkUniversalSet()
        Builds an ExternalSet 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 the pos-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 class java.lang.Object