Interface InterningSet<E>

All Superinterfaces:
Collection<E>, Iterable<E>, Set<E>
All Known Implementing Classes:
Pool, SegmentSequence.SegmentSequencePool, SegmentSequence.StringArrayPool, URI.URIPool, WeakInterningHashSet

public interface InterningSet<E> extends Set<E>
A set that supports intern and get. It's useful for maintaining a cache of instances.
Since:
2.9
  • Method Details

    • intern

      E intern(E object)
      Returns either the instance already contained in the set that's equal to the given object, or adds the object to the set and returns it.
      Parameters:
      object - the object to intern.
      Returns:
      the existing instance already contained in the set equal to the given object, or the object itself (or perhaps in some implementations, an object equal to the object itself).
    • get

      E get(E object)
      Returns either the instance already contained in the set that's equal to the given object, or null if the object is not in the set.
      Parameters:
      object - the object to intern.
      Returns:
      the existing instance already contained in the set equal to the given object, or null if the object is not in the set.