|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jcs.utils.struct.SortedPreferentialArray
This maintains a sorted array with a preferential replacement policy when full. Insertion time is n, search is log(n) Clients must manage thread safety on previous version. I synchronized the public methods to add easy thread safety. I synchronized all public methods that make modifications.
Constructor Summary | |
SortedPreferentialArray(int maxSize)
Consruct the array with the maximum size. |
Method Summary | |
void |
add(java.lang.Comparable obj)
If the array is full this will remove the smallest if preferLarge==true and if obj is bigger, or the largest if preferLarge=false and obj is smaller than the largest. |
protected java.lang.String |
dumpArray()
Debugging method to return a human readable display of array data. |
java.lang.Comparable |
getLargest()
Returns the largest without removing it from the array. |
java.lang.Comparable |
getSmallest()
Returns the smallest element without removing it from the array. |
void |
setPreferLarge(boolean pref)
Determines whether the preference is for large or small. |
int |
size()
Returns the current size of the array. |
java.lang.Comparable |
takeNearestLargerOrEqual(java.lang.Comparable obj)
Returns and removes the nearer larger or equal object from the aray. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SortedPreferentialArray(int maxSize)
maxSize
- intMethod Detail |
public void add(java.lang.Comparable obj)
obj
- Objectpublic java.lang.Comparable getLargest()
public java.lang.Comparable getSmallest()
public void setPreferLarge(boolean pref)
pref
- booleanpublic java.lang.Comparable takeNearestLargerOrEqual(java.lang.Comparable obj)
obj
- Comparable
public int size()
protected java.lang.String dumpArray()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |