com.planet_ink.coffee_mud.core.collections
Class PrioritizingLimitedMap<T extends java.lang.Comparable<T>,K>

java.lang.Object
  extended by com.planet_ink.coffee_mud.core.collections.PrioritizingLimitedMap<T,K>
All Implemented Interfaces:
java.util.Map<T,K>

public class PrioritizingLimitedMap<T extends java.lang.Comparable<T>,K>
extends java.lang.Object
implements java.util.Map<T,K>


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
protected  com.planet_ink.coffee_mud.core.collections.PrioritizingLimitedMap.LinkedEntry<T,K> head
           
protected  int itemLimit
           
protected  java.util.SortedMap<T,com.planet_ink.coffee_mud.core.collections.PrioritizingLimitedMap.LinkedEntry<T,K>> map
           
protected  long maxAgeLimitMillis
           
protected  int origItemLimit
           
protected  com.planet_ink.coffee_mud.core.collections.PrioritizingLimitedMap.LinkedEntry<T,K> tail
           
protected  int threshHoldToExpand
           
protected  long touchAgeLimitMillis
           
protected  java.util.concurrent.atomic.AtomicBoolean trimming
           
 
Constructor Summary
PrioritizingLimitedMap(int itemLimit, long touchAgeLimitMillis, long maxAgeLimitMillis)
          Constructed a "limit" tree-based map.
PrioritizingLimitedMap(int itemLimit, long touchAgeLimitMillis, long maxAgeLimitMillis, int threshHoldToExpand)
          Constructed a "limit" tree-based map.
 
Method Summary
 void clear()
           
 boolean containsKey(java.lang.Object arg0)
           
 boolean containsValue(java.lang.Object arg0)
           
 java.util.Set<java.util.Map.Entry<T,K>> entrySet()
           
 K get(java.lang.Object key)
           
 boolean isEmpty()
           
 java.util.Set<T> keySet()
           
 java.util.Enumeration<T> prioritizedKeys()
           
 K put(T arg0, K arg1)
           
 void putAll(java.util.Map<? extends T,? extends K> arg0)
           
 K remove(java.lang.Object arg0)
           
 int size()
           
 java.util.Collection<K> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

itemLimit

protected int itemLimit

origItemLimit

protected final int origItemLimit

touchAgeLimitMillis

protected final long touchAgeLimitMillis

maxAgeLimitMillis

protected final long maxAgeLimitMillis

threshHoldToExpand

protected final int threshHoldToExpand

trimming

protected final java.util.concurrent.atomic.AtomicBoolean trimming

head

protected volatile com.planet_ink.coffee_mud.core.collections.PrioritizingLimitedMap.LinkedEntry<T extends java.lang.Comparable<T>,K> head

tail

protected volatile com.planet_ink.coffee_mud.core.collections.PrioritizingLimitedMap.LinkedEntry<T extends java.lang.Comparable<T>,K> tail

map

protected final java.util.SortedMap<T extends java.lang.Comparable<T>,com.planet_ink.coffee_mud.core.collections.PrioritizingLimitedMap.LinkedEntry<T extends java.lang.Comparable<T>,K>> map
Constructor Detail

PrioritizingLimitedMap

public PrioritizingLimitedMap(int itemLimit,
                              long touchAgeLimitMillis,
                              long maxAgeLimitMillis,
                              int threshHoldToExpand)
Constructed a "limit" tree-based map. All the parameters here are somewhat fuzzy. The itemLimit will be ignored if lots of youngsters come flooding in. If the itemLimit is exceeded by more than 2* the touch/max age, then those ages will be similarly divided to clean out newer and newer entries in order to at least approach the itemLimit standards. itemLimit, is therefore, a long-run ideal. The threshold to expand is the only hard limit.

Parameters:
itemLimit - the number of items to try to limit this map to
touchAgeLimitMillis - the age of last-touching that makes an item too old to keep
maxAgeLimitMillis - the longest amount of time any entry is allowed to live, regardless of touching
threshHoldToExpand - the number of touches on any given item before the limit expands to accommodate

PrioritizingLimitedMap

public PrioritizingLimitedMap(int itemLimit,
                              long touchAgeLimitMillis,
                              long maxAgeLimitMillis)
Constructed a "limit" tree-based map. All the parameters here are somewhat fuzzy. The itemLimit will be ignored if lots of youngsters come flooding in. If the itemLimit is exceeded by more than 2* the touch/max age, then those ages will be similarly divided to clean out newer and newer entries in order to at least approach the itemLimit standards. itemLimit, is therefore, a long-run ideal.

Parameters:
itemLimit - the number of items to try to limit this map to
touchAgeLimitMillis - the age of last-touching that makes an item too old to keep
maxAgeLimitMillis - the longest amount of time any entry is allowed to live, regardless of touching
Method Detail

get

public K get(java.lang.Object key)
Specified by:
get in interface java.util.Map<T extends java.lang.Comparable<T>,K>

clear

public void clear()
Specified by:
clear in interface java.util.Map<T extends java.lang.Comparable<T>,K>

containsKey

public boolean containsKey(java.lang.Object arg0)
Specified by:
containsKey in interface java.util.Map<T extends java.lang.Comparable<T>,K>

prioritizedKeys

public java.util.Enumeration<T> prioritizedKeys()

containsValue

public boolean containsValue(java.lang.Object arg0)
Specified by:
containsValue in interface java.util.Map<T extends java.lang.Comparable<T>,K>

entrySet

public java.util.Set<java.util.Map.Entry<T,K>> entrySet()
Specified by:
entrySet in interface java.util.Map<T extends java.lang.Comparable<T>,K>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map<T extends java.lang.Comparable<T>,K>

keySet

public java.util.Set<T> keySet()
Specified by:
keySet in interface java.util.Map<T extends java.lang.Comparable<T>,K>

put

public K put(T arg0,
             K arg1)
Specified by:
put in interface java.util.Map<T extends java.lang.Comparable<T>,K>

putAll

public void putAll(java.util.Map<? extends T,? extends K> arg0)
Specified by:
putAll in interface java.util.Map<T extends java.lang.Comparable<T>,K>

remove

public K remove(java.lang.Object arg0)
Specified by:
remove in interface java.util.Map<T extends java.lang.Comparable<T>,K>

size

public int size()
Specified by:
size in interface java.util.Map<T extends java.lang.Comparable<T>,K>

values

public java.util.Collection<K> values()
Specified by:
values in interface java.util.Map<T extends java.lang.Comparable<T>,K>