|
JTemporal Home Tutorial |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.jtemporal.spi.CompactPeriodStorage
public class CompactPeriodStorage
A sorted storage for Periods, intended to allocate a small
amount of memory; fast for small collections, but does not scale well
for insertions in large collections.
The internal storage is based on a sorted ArrayList.
Given that for each put(Period)
or remove(Period) in average
50% of the records are moved, write performance of this
storage does not scale well.
the arraylist is instantiated only the first time
put(Period) is called.
| Constructor Summary | |
|---|---|
CompactPeriodStorage()
|
|
| Method Summary | |
|---|---|
void |
clear()
Removes all the stored periods. |
Period |
firstPeriod()
Returns the first (lowest) period currently in this storage, or null if any is found. |
Period |
firstPeriod(Period p)
|
Period |
getPeriod(Instant instant)
Returns the period valid at the specified instant. |
Period |
getPeriodEndingAt(Instant instant)
Returns the period finishing exactly at the given instant, if any is found. |
Period |
getPeriodStartingAt(Instant instant)
Returns the period starting exactly at the given instant, if any is found. |
boolean |
isEmpty()
Returns true if this storage does not contain objects. |
boolean |
isEmpty(Period p)
Returns true if this storage does not contain objects intersecting the given period. |
Period |
lastPeriod()
Returns the last (highest) period currently in this storage or null if empty. |
Period |
lastPeriod(Period p)
|
CloseableIterator |
periodIterator()
Iterates over all the periods of the entries. |
CloseableIterator |
periodIterator(Period period)
Iterates over all the periods of the storage that intersects the given period. |
void |
put(Period p)
Stores a period. |
void |
remove(Period p)
Removes a period previously stored. |
int |
size()
Returns the number of Periods in this storage. |
java.lang.String |
toString()
|
void |
trimToSize()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public CompactPeriodStorage()
| Method Detail |
|---|
public Period lastPeriod()
PeriodStorage
lastPeriod in interface PeriodStoragepublic Period lastPeriod(Period p)
public Period firstPeriod()
PeriodStorage
firstPeriod in interface PeriodStoragepublic Period firstPeriod(Period p)
public boolean isEmpty()
PeriodStorage
isEmpty in interface PeriodStoragepublic boolean isEmpty(Period p)
PeriodStorage
isEmpty in interface PeriodStoragep - the intersecting period
public Period getPeriod(Instant instant)
PeriodStorage
getPeriod in interface PeriodStorageinstant - the instant whose enclosing period must be returned
public void put(Period p)
PeriodStorage
put in interface PeriodStoragep - period to be added to the storage. Cannot be null.public void remove(Period p)
PeriodStorage
remove in interface PeriodStoragep - the period to be removedpublic Period getPeriodEndingAt(Instant instant)
PeriodStorage
getPeriodEndingAt in interface PeriodStorageinstant - the instant the equals the entry end
public Period getPeriodStartingAt(Instant instant)
PeriodStorage
getPeriodStartingAt in interface PeriodStorageinstant - the instant the equals the entry end
public void clear()
PeriodStorage
clear in interface PeriodStoragepublic int size()
PeriodStorage
size in interface PeriodStoragepublic CloseableIterator periodIterator(Period period)
PeriodStorage
periodIterator in interface PeriodStorageperiod - the intersecting period.
Periodpublic CloseableIterator periodIterator()
PeriodStorage
periodIterator in interface PeriodStoragePeriodpublic void trimToSize()
ArrayList.trimToSize()public java.lang.String toString()
toString in class java.lang.Object
|
JTemporal Home Tutorial |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||