Package org.eclipse.emf.common.util
Class SegmentSequence.SegmentSequencePool
java.lang.Object
java.util.AbstractCollection<SegmentSequence>
java.util.AbstractSet<SegmentSequence>
org.eclipse.emf.common.util.WeakInterningHashSet<SegmentSequence>
org.eclipse.emf.common.util.Pool<SegmentSequence>
org.eclipse.emf.common.util.SegmentSequence.SegmentSequencePool
- All Implemented Interfaces:
Serializable,Iterable<SegmentSequence>,Collection<SegmentSequence>,Set<SegmentSequence>,InterningSet<SegmentSequence>
- Enclosing class:
SegmentSequence
A cached pool of weakly referenced segment sequences.
There are several ways of interning instances, all of which seek to avoid creating new objects whenever possible.
Note that we've carefully ensured that a segment sequence's hash code is the same as that of its string representation.
This is exploited to allow fast lookup of strings against their already segmented representation.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA base class for all this pool's access units.protected static classprotected static classAn access unit for accessing a delimiter and segments.protected static classAn access unit for accessing segments and one additional segment.protected static classAn access units for accessing the composition of two sets of segments.protected static classAn access unit for basic string access.Nested classes/interfaces inherited from class org.eclipse.emf.common.util.Pool
Pool.AccessUnit<E>, Pool.ExternalRehasher<E>, Pool.ObjectAccessUnit<E>, Pool.PoolEntry<E>Nested classes/interfaces inherited from class org.eclipse.emf.common.util.WeakInterningHashSet
WeakInterningHashSet.Entry<E>, WeakInterningHashSet.SelfCleaningEntry<E> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ReferenceQueue<String> A reference queue for internally managing the collection of cachedSegmentSequence.toStrings.protected final SegmentSequence.SegmentSequencePool.SegmentsAccessUnit.QueueAccess units for accessing a delimiter and segments.Access units for accessing segments and one additional segment.Access units for accessing the composition of two sequences of segments.protected final SegmentSequence.SegmentSequencePool.StringAccessUnit.QueueAccess units for basic string access.Fields inherited from class org.eclipse.emf.common.util.Pool
accessCount, cleanupPeriod, primaryAccessUnits, readLock, readWriteLock, writeLockFields inherited from class org.eclipse.emf.common.util.WeakInterningHashSet
capacityIndex, containsNull, entries, externalQueue, internalQueue, modCount, NULL_ENTRY, PRIME_CAPACITIES, size, threshold -
Constructor Summary
ConstructorsConstructorDescriptionSegmentSequencePool(ReferenceQueue<Object> queue) Creates an instance managed the given external queue. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidSpecialized to also clean up thecachedToStrings.protected SegmentSequenceInterns the segments, taking into account the delimiter, copying the array, when needed, and interning the segments themselves, when needed.protected SegmentSequenceInterns the segments along with the one additional segment, taking into account the delimiter and interning the additional segment.protected SegmentSequenceintern(int hashCode, String delimiter, String[] segments1, String[] segments2, boolean needsToIntern) Interns the composed segments, taking into account the delimiter.protected SegmentSequenceInterns the string representation of a segment sequence, splitting it into appropriate segments based on the delimiter.protected WeakReference<String> newCachedToString(SegmentSequence segmentSequence, String string) Methods inherited from class org.eclipse.emf.common.util.Pool
access, add, addEntry, cleanup, clear, contains, containsAll, doIntern, ensureCapacity, equals, get, getEntry, getReadLock, getWriteLock, grow, hashCode, intern, iterator, newDefaultAccessUnits, newExternalEntry, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class org.eclipse.emf.common.util.WeakInterningHashSet
addEntry, asInstance, dump, equals, hashCode, index, newEntries, newEntry, newInternalEntry, nullEntry, putEntry, removeEntry, removeEntry, sizeMethods inherited from class java.util.AbstractCollection
addAll, isEmptyMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
addAll, isEmpty, spliterator
-
Field Details
-
stringAccessUnits
Access units for basic string access. -
segmentsAccessUnits
Access units for accessing a delimiter and segments. -
segmentsAndSegmentAccessUnits
protected final SegmentSequence.SegmentSequencePool.SegmentsAndSegmentAccessUnit.Queue segmentsAndSegmentAccessUnitsAccess units for accessing segments and one additional segment. -
segmentsAndSegmentsAccessUnits
protected final SegmentSequence.SegmentSequencePool.SegmentsAndSegmentsAccessUnit.Queue segmentsAndSegmentsAccessUnitsAccess units for accessing the composition of two sequences of segments. -
cachedToStrings
A reference queue for internally managing the collection of cachedSegmentSequence.toStrings.
-
-
Constructor Details
-
SegmentSequencePool
Creates an instance managed the given external queue. If it'snull, and internal queue will be used to managed the cached strings.
-
-
Method Details
-
doCleanup
protected void doCleanup()Specialized to also clean up thecachedToStrings.- Overrides:
doCleanupin classPool<SegmentSequence>
-
newCachedToString
-
intern
Interns the string representation of a segment sequence, splitting it into appropriate segments based on the delimiter. -
intern
protected SegmentSequence intern(boolean needsCopying, boolean needsToIntern, String delimiter, String[] segments, int count) Interns the segments, taking into account the delimiter, copying the array, when needed, and interning the segments themselves, when needed. -
intern
Interns the segments along with the one additional segment, taking into account the delimiter and interning the additional segment. All callers of this method will already have interned the segments. -
intern
protected SegmentSequence intern(int hashCode, String delimiter, String[] segments1, String[] segments2, boolean needsToIntern) Interns the composed segments, taking into account the delimiter. All callers of this method will already have interned the segments.
-