|
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.AbstractTemporalSet<V> net.sf.jtemporal.TreeTemporalSet<V>
V
- the type of the valuepublic class TreeTemporalSet<V>
Maintains internally a TreeMap over the periods and an HashMap over the values
so that query performances are acceptable for queries in both dimensions even when
the collection is very large.
Note: this implementation is not synchronized. If multiple
threads access the map concurrently, and at least one of the threads modifies
the map structurally, it must be synchronized externally. (A
structural modification is any operation that adds or deletes one or more
mappings; merely changing the value associated with an existing key is not
a structural modification.) This is typically accomplished by
synchronizing on some object that naturally encapsulates the map. If no
such object exists, the map should be "wrapped" using the
SynchronizedTemporalMultiMap.getInstance method. This is best done at creation
time, to prevent accidental unsynchronized access to the map:
TemporalSet tm = SynchronizedTemporalMap.getInstance(new TreeTemporalSet(...));
Note the synchronizing proxies are not available yet.
(internal structure)
In a future version, this structure will be optimized in order to reduce the
memory usage when the map contains few values.
Constructor Summary | |
---|---|
TreeTemporalSet()
Default constructor. |
|
TreeTemporalSet(java.lang.Class valueType)
|
Method Summary | |
---|---|
void |
clear()
Removes all the mappings from this map. |
boolean |
contains(Instant instant,
java.lang.Object value)
Returns true if there is a mapping for this value at the given instant. |
boolean |
containsValue(java.lang.Object value)
Returns true if there is a mapping for the specified value. |
java.util.Set<TimedObject<V>> |
entrySet()
Returns a set view of the entries (instances of TimedObject) contained in this map. |
Instant |
firstInstant(java.lang.Object value)
Returns the first (lowest) instant currently defined for the given value. |
Period |
firstPeriod(java.lang.Object value)
Returns the first (lowest) period currently defined for the given value. |
Period |
getPeriod(Instant instant,
java.lang.Object value)
Returns the period of the mapping valid at the specified instant for the given value. |
boolean |
isEmpty()
Returns true if this map contains no Period-value mappings. |
boolean |
isEmpty(Instant i)
Returns true if this map does not contain mappings valid at the given intant. |
Instant |
lastInstant(java.lang.Object value)
Returns the last (highest) instant currently defined for the given value. |
Period |
lastPeriod(java.lang.Object value)
Returns the last (highest) period currently defined for the given value. |
java.util.Set<Period> |
periodSet(java.lang.Object value)
Returns a set view of the periods contained in this map for the give value. |
boolean |
put(Period p,
V value)
Associates the specified value with the specified Period in this map. |
boolean |
remove(Period p,
java.lang.Object value)
Removes the mapping(s) for this period and value from this map if present. |
boolean |
removePeriod(Period p)
Removes all the mapping(s) for this period from this map if present. |
boolean |
removeValue(java.lang.Object value)
Removes all the mapping(s) for this value from this map if present. |
int |
size()
Returns the number of Period-value mappings in this map. |
int |
sizeAt(Instant instant)
Returns the number values in this map valid at the given instant. |
int |
sizeFor(java.lang.Object value)
Returns the number of Period-value mappings in this map for the given value. |
int |
sizeValues()
Returns the number of distinct values in this map. |
java.util.Set<V> |
valueSet()
Returns a read-only Set containing the distinct values defined somewhen in this map. |
java.util.Set<V> |
valueSet(Instant instant)
Returns a read-only Set containing the values defined in this map at the specified instant. |
Methods inherited from class net.sf.jtemporal.AbstractTemporalSet |
---|
equals, extent, putAll |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TreeTemporalSet()
public TreeTemporalSet(java.lang.Class valueType)
valueType
- values must be of this type.Method Detail |
---|
public Instant firstInstant(java.lang.Object value)
TemporalSet
public Instant lastInstant(java.lang.Object value)
TemporalSet
public Period getPeriod(Instant instant, java.lang.Object value)
TemporalSet
instant
- when the given value is validvalue
- the value of the entry valid during the returned period
public boolean contains(Instant instant, java.lang.Object value)
TemporalSet
instant
- instant whose presence in this map is to be tested.value
- value whose presence in this map is to be tested.
public boolean containsValue(java.lang.Object value)
TemporalSet
value
- value whose presence in this map is to be tested.
public Period firstPeriod(java.lang.Object value)
TemporalSet
public Period lastPeriod(java.lang.Object value)
TemporalSet
public boolean isEmpty()
TemporalSet
public int sizeFor(java.lang.Object value)
TemporalSet
value
- the number of entries for the given value
public int sizeAt(Instant instant)
TemporalSet
instant
- the instant at which the counted entries are valid
public int size()
TemporalSet
public int sizeValues()
TemporalSet
public java.util.Set<TimedObject<V>> entrySet()
TemporalSet
TimedObject
public boolean isEmpty(Instant i)
TemporalSet
i
- when this temporal set is empty
public java.util.Set<Period> periodSet(java.lang.Object value)
TemporalSet
public java.util.Set<V> valueSet()
TemporalSet
public java.util.Set<V> valueSet(Instant instant)
TemporalSet
instant
- instant whose associated value is to be returned
public void clear()
TemporalSet
public boolean removeValue(java.lang.Object value)
TemporalSet
value
- value whose mapping are to be removed from the map.
true
if the TemporalSet contained the specified element.public boolean remove(Period p, java.lang.Object value)
TemporalSet
p
- period whose mappings are to be removed from the map.value
- value whose mapping are to be removed from the map.
public boolean removePeriod(Period p)
TemporalSet
p
- period whose mappings are to be removed from the map.
public boolean put(Period p, V value)
TemporalSet
p
- period with which the specified value is to be associated.value
- value to be associated with the specified period. Be careful
at the equals implementation of the value object: the result of the equals
method is supposed to be immutable while it is stored in this collection.
|
JTemporal Home Tutorial |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |