|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.eliad.util.SizeCache
A mechanism to cache size/position information as defined in
Intervals.
This will cache information in the zone specified by setCachedRange(int, int).
The sizes and positions at the first and last positions are also cached.
This gives in the cached range O(1) behavior for getSize and getPosition,
and O(Log(k)) for getIndex where k is the size of the cached range.
If the Interval object hasFixedSize, no caching is done.
| Constructor Summary | |
SizeCache(Intervals intervals)
Constructs a cache above an Intervals object>.
|
|
| Method Summary | |
void |
entriesInserted(int start,
int count)
A post call-back for entries insertion |
void |
entriesRemoved(int start,
int count)
A post call-back for entries removal |
void |
entryUpdated(int index,
int old,
int size)
A post call-back for entry update |
int |
getCount()
Returns the number of entries in the cached Intervals object. |
int |
getIndex(int position)
Returns the index of the entry that corresponds to the specified position. |
Intervals |
getIntervals()
|
int |
getPosition(int index)
Returns the start position for the specified entry. |
int |
getSize(int index)
Retrieves the size of the specified entry, from the cache if possible. |
void |
insertEntries(int start,
int length,
int value)
Transmits entries insertion to the underlying Intervals object.
|
void |
invalidateCache(int from,
int count)
Takes into account global modifications, specifically, size modifications beginning with from and extending according the the size of the count. |
void |
removeEntries(int start,
int length)
Transmits entries removal to the underlying Intervals object.
|
void |
setCachedRange(int start,
int length)
Specifies the region to be cached |
void |
setSize(int index,
int size)
Transmits an update to the size of the specified entry to the underlying Intervals object.
|
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public SizeCache(Intervals intervals)
Intervals object>.
There can be any number of caches over a given object.| Method Detail |
public Intervals getIntervals()
public final int getCount()
Intervals object.public int getSize(int index)
index - the index corresponding to the entrypublic int getPosition(int index)
index - the index of the entry with the desired positionpublic int getIndex(int position)
position - the position of the entry
public void setSize(int index,
int size)
Intervals object.
Whenever the setSize method
of the underlying object is invoked, directly or indirectly,
the entryUpdated method must be called for any cache on this
Intervals otherwise the cache will be broken.index - the index corresponding to the entrysize - the size of the entry
public void insertEntries(int start,
int length,
int value)
Intervals object.
Whenever the insertEntriesmethod
of the underlying object is invoked, directly or indirectly,
the entriesInserted method must be called for any cache on this
Intervals otherwise the cache will be broken.start - the start index of the insertionslength - the number of inserted entriesvalue - the value of the new entries.
public void removeEntries(int start,
int length)
Intervals object.
Whenever the removeEntriesmethod
of the underlying object is invoked, directly or indirectly,
the entriesRemoved method must be called for any cache on this
Intervals otherwise the cache will be broken.start - the start index of the removallength - the number of removed entries
public void setCachedRange(int start,
int length)
start - the first position in the cachelength - the number of items we need to cache.
public void invalidateCache(int from,
int count)
from and extending according the the size of the count.index - the first index where
something may have changed.length - the number of entries that may have changed,
-1 means to the end
public void entryUpdated(int index,
int old,
int size)
index - the index of the entry whose size was just updated.size - the new sizeold - the old size
public void entriesInserted(int start,
int count)
start - the index where the first entry was just inserted.length - the number of entries that were just inserted.value - the size that was just given to the new entries
public void entriesRemoved(int start,
int count)
start - the index where the first entry was just removed.count - the number of entries that were just removed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||