Package io.timeandspace.collect
Interface ObjSet<E>
-
- All Superinterfaces:
Collection<E>
,Iterable<E>
,ObjCollection<E>
,Set<E>
public interface ObjSet<E> extends Set<E>, ObjCollection<E>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @Nullable E
getInternal(E e)
Returns the object held by this set internally and equivalent to the given objecte
, if there is one, ornull
if this set contains no such element (optional operation).-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface io.timeandspace.collect.ObjCollection
forEachWhile, sizeAsLong
-
-
-
-
Method Detail
-
getInternal
@Nullable E getInternal(E e)
Returns the object held by this set internally and equivalent to the given objecte
, if there is one, ornull
if this set contains no such element (optional operation).This method could be used to deduplicate objects in the application, to reduce the memory footprint and make the application to conform to the "most objects die young" hypothesis that most GC algorithms are optimized for. This method is functionally similar to
String.intern()
and Guava's Interner, but allows to piggy-back a map data structure which may already exist in the application.- Parameters:
e
- the object whose equivalent held by this set internally is to be returned- Returns:
- the set-internal equivalent of the specified object, or
null
if the set contains no such element - Throws:
UnsupportedOperationException
- if this set doesn't support returning an internal copy of an element, e. g. because it's a "virtual" view of another collection
-
-