|
JTemporal Home Tutorial |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.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 PeriodStorage
public Period lastPeriod(Period p)
public Period firstPeriod()
PeriodStorage
firstPeriod
in interface PeriodStorage
public Period firstPeriod(Period p)
public boolean isEmpty()
PeriodStorage
isEmpty
in interface PeriodStorage
public boolean isEmpty(Period p)
PeriodStorage
isEmpty
in interface PeriodStorage
p
- the intersecting period
public Period getPeriod(Instant instant)
PeriodStorage
getPeriod
in interface PeriodStorage
instant
- the instant whose enclosing period must be returned
public void put(Period p)
PeriodStorage
put
in interface PeriodStorage
p
- period to be added to the storage. Cannot be null.public void remove(Period p)
PeriodStorage
remove
in interface PeriodStorage
p
- the period to be removedpublic Period getPeriodEndingAt(Instant instant)
PeriodStorage
getPeriodEndingAt
in interface PeriodStorage
instant
- the instant the equals the entry end
public Period getPeriodStartingAt(Instant instant)
PeriodStorage
getPeriodStartingAt
in interface PeriodStorage
instant
- the instant the equals the entry end
public void clear()
PeriodStorage
clear
in interface PeriodStorage
public int size()
PeriodStorage
size
in interface PeriodStorage
public CloseableIterator periodIterator(Period period)
PeriodStorage
periodIterator
in interface PeriodStorage
period
- the intersecting period.
Period
public CloseableIterator periodIterator()
PeriodStorage
periodIterator
in interface PeriodStorage
Period
public 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 |