|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.vostok.lang.PriorityList
public class PriorityList
A List that reorders its childs according to the frequence of access.
A priority list should be used when target element position's cannot be determined in advence, so a sequencial iteration must be used but the deviation is narrow. Each time a request is done for a specific element, its position change, up on the list, therefore, when doing a sequencial iteration it's likely to be checked sooner.
Field Summary | |
---|---|
protected Entry[] |
array
internal array of data, ordered : first = most used |
static int |
DEFAULT_GROW_STEP
Default growing step for the internal array when adding new element |
static float |
DEFAULT_ITEM_RELOCATION_DEPRECIATION
when a match is found outside the priority zone, the item must be relocated up. 1.0f mean directly up to the top, 0.0f mean no relocation at all ! |
static float |
DEFAULT_PRIORITY_ZONE
if a matching glob is found into this percent of the array, it's known to be into the priority zone, therefore, no need of relocation . default 15% |
static float |
DEFAULT_PRIORITY_ZONE_DEPRECIATION
every time the array grow (actuallualy at every grow step), the area covered by the priority zone is depreciate. |
static int |
DEFAULT_SIZE
the initial size of the array |
protected int |
growStep
|
protected float |
initialPriorityZone
|
protected int |
initialSize
|
protected float |
itemDepreciation
|
protected float |
priorityDepreciation
|
protected float |
priorityZone
|
protected int |
size
real number of slot actually used |
Constructor Summary | |
---|---|
PriorityList()
Create a new List, with default values |
|
PriorityList(int initialSize,
int growStep,
float priorityZone,
float priorityDepreciation,
float itemDepreciation)
Create a new list |
Method Summary | ||
---|---|---|
boolean |
add(Entry e)
add new entry to the list. |
|
boolean |
add(java.lang.String key)
add an Entry where key == obj convenience method same as add(new Entry(key,key)) |
|
boolean |
addAll(java.util.Collection<? extends Entry> c)
add all Entry from c. |
|
void |
clear()
erase all data from the list |
|
boolean |
contains(java.lang.Object o)
return true if the list contain the element o |
|
boolean |
containsAll(java.util.Collection<?> c)
method inherit from Collection. |
|
Entry |
find(java.lang.Comparable<Entry> comparable)
Find en entry using a comparator. |
|
Entry |
find(Entry e)
Find en entry using an Entry object. check is done against both hashkey, which only use their key. |
|
Entry |
find(java.lang.String key)
Find entry by key. |
|
int |
findPosition(Entry o)
find position of an entry. |
|
int |
findPosition(java.lang.String key)
find position of an entry. |
|
boolean |
isEmpty()
return true if the list is empty |
|
java.util.Iterator<Entry> |
iterator()
return a new iterator on the list's elements |
|
boolean |
remove(java.lang.Object o)
Remove entry using it's object as source. |
|
boolean |
removeAll(java.util.Collection<?> c)
method inherit from Collection. |
|
boolean |
removeByKey(java.lang.String key)
remove an entry from the list using it's key |
|
boolean |
retainAll(java.util.Collection<?> c)
method inherit from Collection. |
|
int |
size()
return the size of the list. |
|
java.lang.Object[] |
toArray()
|
|
|
toArray(T[] a)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
equals, hashCode |
Field Detail |
---|
public static final int DEFAULT_SIZE
public static final int DEFAULT_GROW_STEP
public static final float DEFAULT_PRIORITY_ZONE
public static final float DEFAULT_PRIORITY_ZONE_DEPRECIATION
public static final float DEFAULT_ITEM_RELOCATION_DEPRECIATION
protected Entry[] array
protected final int initialSize
protected final float initialPriorityZone
protected final int growStep
protected final float priorityDepreciation
protected final float itemDepreciation
protected float priorityZone
protected int size
Constructor Detail |
---|
public PriorityList()
public PriorityList(int initialSize, int growStep, float priorityZone, float priorityDepreciation, float itemDepreciation) throws java.lang.IllegalArgumentException
initialSize
- : initial size of the buffer, before it grows automatically of growStepgrowStep
- : Step the buffer must increase each timepriorityZone
- priorityDepreciation
- itemDepreciation
-
java.lang.IllegalArgumentException
Method Detail |
---|
public Entry find(java.lang.Comparable<Entry> comparable)
comparable
-
public Entry find(java.lang.String key)
public Entry find(Entry e)
public int findPosition(java.lang.String key)
key
-
public int findPosition(Entry o)
o
-
public int size()
size
in interface java.util.Collection<Entry>
public boolean isEmpty()
isEmpty
in interface java.util.Collection<Entry>
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<Entry>
o
-
public java.util.Iterator<Entry> iterator()
iterator
in interface java.lang.Iterable<Entry>
iterator
in interface java.util.Collection<Entry>
PriorityListIterator
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<Entry>
public <T> T[] toArray(T[] a)
toArray
in interface java.util.Collection<Entry>
public boolean add(Entry e)
add
in interface java.util.Collection<Entry>
e
-
public boolean add(java.lang.String key)
key
-
public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<Entry>
o
-
public boolean removeByKey(java.lang.String key)
key
-
public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<Entry>
c
-
public boolean addAll(java.util.Collection<? extends Entry> c)
addAll
in interface java.util.Collection<Entry>
c
-
public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<Entry>
c
-
public boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<Entry>
c
-
public void clear()
clear
in interface java.util.Collection<Entry>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |