Class LRUSet<ELEMENTTYPE>
java.lang.Object
java.util.AbstractCollection<ELEMENTTYPE>
java.util.AbstractSet<ELEMENTTYPE>
com.helger.commons.collection.map.LRUSet<ELEMENTTYPE>
- Type Parameters:
ELEMENTTYPE- Element type
- All Implemented Interfaces:
ICommonsCollection<ELEMENTTYPE>,ICommonsIterable<ELEMENTTYPE>,ICommonsOrderedSet<ELEMENTTYPE>,ICommonsSet<ELEMENTTYPE>,ICloneable<ICommonsSet<ELEMENTTYPE>>,IHasSize,Iterable<ELEMENTTYPE>,Collection<ELEMENTTYPE>,Set<ELEMENTTYPE>
@NotThreadSafe
@UseDirectEqualsAndHashCode
public class LRUSet<ELEMENTTYPE>
extends AbstractSet<ELEMENTTYPE>
implements ICommonsOrderedSet<ELEMENTTYPE>
A special ordered set, that has an upper limit of contained elements. It is
therefore a "Last Recently Used" cache.
The underlying data structure is a
The underlying data structure is a
LRUMap map.- Author:
- Philip Helger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(ELEMENTTYPE aItem) booleangetClone()final intinthashCode()iterator()protected voidonRemoveEldestEntry(int nSize, ELEMENTTYPE aEldest) Protected method that is invoked every time an element is removed from the cache, because the maximum size is exceeded.intsize()toString()Methods inherited from class java.util.AbstractSet
removeAllMethods inherited from class java.util.AbstractCollection
addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArrayMethods 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 com.helger.commons.collection.impl.ICommonsCollection
addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addIf, addIfNotNull, addObject, getAtIndex, getAtIndex, getAtIndex, getAtIndex, getAtIndexMapped, getAtIndexMapped, getAtIndexMapped, getAtIndexMapped, getCopyAsList, getCount, getSorted, iterator2, removeAll, removeObject, set, setAll, setAll, setAllMapped, setAllMappedMethods inherited from interface com.helger.commons.collection.impl.ICommonsIterable
containsAny, containsNone, containsOnly, findAll, findAllInstanceOf, findAllMapped, findAllMapped, findAllMapped, findFirst, findFirst, findFirstIndex, findFirstMapped, findFirstMapped, findLastIndex, forEachBreakable, forEachByIndex, forEachThrowing, getCountMethods inherited from interface com.helger.commons.collection.impl.ICommonsOrderedSet
createInstance, getAll, getAllInstanceOf, getAllMapped, getAllMapped, getFirst, getFirst, getLast, getLastMethods inherited from interface com.helger.commons.collection.impl.ICommonsSet
getAsUnmodifiable, replaceMethods inherited from interface com.helger.commons.lang.IHasSize
isEmpty, isNotEmpty
-
Constructor Details
-
LRUSet
-
LRUSet
-
-
Method Details
-
getClone
- Specified by:
getClonein interfaceICloneable<ELEMENTTYPE>- Specified by:
getClonein interfaceICommonsOrderedSet<ELEMENTTYPE>- Returns:
- A 100% deep-copy of the implementing class.
-
onRemoveEldestEntry
@OverrideOnDemand protected void onRemoveEldestEntry(@Nonnegative int nSize, @Nonnull ELEMENTTYPE aEldest) Protected method that is invoked every time an element is removed from the cache, because the maximum size is exceeded.- Parameters:
nSize- Current size of the map. Always ≥ 0.aEldest- The entry that is to be removed. Nevernull.
-
getMaxSize
- Returns:
- The maximum number of elements that can reside in this cache.
-
add
- Specified by:
addin interfaceCollection<ELEMENTTYPE>- Specified by:
addin interfaceSet<ELEMENTTYPE>- Overrides:
addin classAbstractCollection<ELEMENTTYPE>
-
iterator
- Specified by:
iteratorin interfaceCollection<ELEMENTTYPE>- Specified by:
iteratorin interfaceIterable<ELEMENTTYPE>- Specified by:
iteratorin interfaceSet<ELEMENTTYPE>- Specified by:
iteratorin classAbstractCollection<ELEMENTTYPE>
-
size
- Specified by:
sizein interfaceCollection<ELEMENTTYPE>- Specified by:
sizein interfaceIHasSize- Specified by:
sizein interfaceSet<ELEMENTTYPE>- Specified by:
sizein classAbstractCollection<ELEMENTTYPE>- Returns:
- The number of contained elements. Always ≥ 0.
-
equals
- Specified by:
equalsin interfaceCollection<ELEMENTTYPE>- Specified by:
equalsin interfaceSet<ELEMENTTYPE>- Overrides:
equalsin classAbstractSet<ELEMENTTYPE>
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<ELEMENTTYPE>- Specified by:
hashCodein interfaceSet<ELEMENTTYPE>- Overrides:
hashCodein classAbstractSet<ELEMENTTYPE>
-
toString
- Overrides:
toStringin classAbstractCollection<ELEMENTTYPE>
-