|
Side of Software Dated Collections Library 2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectsos.dated.util.AbstractDatedObject<D>
sos.dated.util.AbstractDatedMap<K,V,D>
sos.dated.util.AbstractMapByDate<K,V,D>
sos.dated.util.TreeMapByDate<K,V,D>
K - the type of keys maintained by this dated mapV - the type of values maintained by this dated mapD - the type of dates used by this dated mappublic class TreeMapByDate<K,V,D>
An implementation of DatedSortedMap that maintains a java.util.TreeMap
at each date where a change occurs, yielding fast date iterations and logarithmic
retrievals. The following illustration shows a conceptual view of a small TreeMapByDate
where the "dates" are integers, the keys are characters, and the values are special
characters:

DatedCollections.synchronizedDatedMap.
TreeMapByKey,
HashMapByDate,
DatedMap,
DatedCollections.synchronizedDatedMap(DatedMap)| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface sos.dated.util.DatedMap |
|---|
DatedMap.Entry<K,V,D> |
| Constructor Summary | |
|---|---|
TreeMapByDate()
Creates an empty TreeMapByKey that sorts its keys
by their natural ordering. |
|
TreeMapByDate(java.util.Comparator<? super K> comparator)
Constructs a TreeMapByDate that uses the specified comparator
to order the keys. |
|
TreeMapByDate(DatedMap<? extends K,? extends V,D> datedMap)
Constructs a TreeMapByDate that uses the natural ordering
of keys and initially contains the mappings of datedMap. |
|
TreeMapByDate(DatedSortedMap<K,? extends V,D> datedSortedMap)
Constructs a TreeMapByDate that initially contains the entries
of datedSortedMap. |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Creates and returns a shallow copy of this object. |
java.util.Comparator<? super K> |
comparator()
Returns the comparator used to sorted the keys of this dated map. |
protected java.util.Map<K,V> |
copyMap(java.util.Map<K,V> map,
D from,
D to)
Returns a new TreeMap initialized with the mappings of
map. |
protected java.util.Map<K,V> |
createMap(D from,
D to)
Returns a freshly created, empty TreeMap. |
K |
firstKey(D date)
Returns the smallest key in this dated map at the specified date. |
DatedSortedMap<K,V,D> |
headMap(K toKey)
Returns a view of this dated map of all mappings whose keys precede toKey. |
K |
lastKey(D date)
Returns the largest key in this dated map at the specified date. |
DatedSortedMap<K,V,D> |
subMap(K fromKey,
K toKey)
Returns a view of this dated map of all mappings whose keys fall between fromKey (inclusive) and toKey (exclusive). |
DatedSortedMap<K,V,D> |
tailMap(K fromKey)
Returns a view of this dated map of all mappings whose keys are greater than or equal to fromKey. |
| Methods inherited from class sos.dated.util.AbstractMapByDate |
|---|
checkForComodification, containsKey, containsValue, dateIterator, entrySet, get, modCount, put, putAll, remove, upModCount |
| Methods inherited from class sos.dated.util.AbstractDatedMap |
|---|
clear, containsKeyThroughout, containsValueThroughout, equals, excludesKeyThroughout, excludesValueThroughout, get, hashCode, hasSizeThroughout, isEmpty, isEmptyThroughout, keySet, size, toString, values |
| Methods inherited from class sos.dated.util.AbstractDatedObject |
|---|
dateIterator, equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface sos.dated.util.DatedMap |
|---|
clear, containsKey, containsKeyThroughout, containsValue, containsValueThroughout, entrySet, equals, excludesKeyThroughout, excludesValueThroughout, get, get, hashCode, hasSizeThroughout, isEmpty, isEmptyThroughout, keySet, put, putAll, remove, size, values |
| Methods inherited from interface sos.dated.util.DatedObject |
|---|
dateIterator, dateIterator, equals, hashCode, toString |
| Constructor Detail |
|---|
public TreeMapByDate()
TreeMapByKey that sorts its keys
by their natural ordering. All keys placed in this map must implement
the Comparable interface.
public TreeMapByDate(DatedMap<? extends K,? extends V,D> datedMap)
TreeMapByDate that uses the natural ordering
of keys and initially contains the mappings of datedMap.
All keys placed in this map must implement the Comparable interface.
datedMap - dated map with which to initialize this TreeMapByDate
java.lang.NullPointerException - if datedMap is null.public TreeMapByDate(java.util.Comparator<? super K> comparator)
TreeMapByDate that uses the specified comparator
to order the keys. The comparator should not throw an exception for
any key placed in this map. A comparator with the value null causes this
map to rely on the natural ordering of the keys.
comparator - object used to order the keys (may be null)public TreeMapByDate(DatedSortedMap<K,? extends V,D> datedSortedMap)
TreeMapByDate that initially contains the entries
of datedSortedMap. This dated map uses the specified dated map's
comparator to order the keys.
datedSortedMap - dated sorted map with which to initialize
this TreeMapByDate
java.lang.NullPointerException - if datedSortedMap is null.| Method Detail |
|---|
public java.lang.Object clone()
AbstractDatedMapclone method.
clone in class AbstractMapByDate<K,V,D>public java.util.Comparator<? super K> comparator()
DatedSortedMap
comparator in interface DatedSortedMap<K,V,D>
protected java.util.Map<K,V> createMap(D from,
D to)
TreeMap.
createMap in class AbstractMapByDate<K,V,D>from - start date (inclusive) for which to create the mapto - end date (exclusive) for which to create the map
TreeMap.
protected java.util.Map<K,V> copyMap(java.util.Map<K,V> map,
D from,
D to)
TreeMap initialized with the mappings of
map.
copyMap in class AbstractMapByDate<K,V,D>map - mappings to be included in the new map
TreeMap initialized with the mappings of
map.public K firstKey(D date)
DatedSortedMap
firstKey in interface DatedSortedMap<K,V,D>date - date for which to find the smallest key
atpublic DatedSortedMap<K,V,D> headMap(K toKey)
DatedSortedMaptoKey.
The key toKey does not have to appear in this dated map nor will it
ever appear in the returned map. The returned map is a fully functional
dated sorted map that is tied to this map. Changes to either will be reflected
in the other. Any attempt to add a key greater than or equal to toKey will
throw an IllegalArgumentException.
headMap in interface DatedSortedMap<K,V,D>toKey - upper bound of the keys of the returned map (exclusive)
public K lastKey(D date)
DatedSortedMap
lastKey in interface DatedSortedMap<K,V,D>date - date for which to find the largest key
at
public DatedSortedMap<K,V,D> subMap(K fromKey,
K toKey)
DatedSortedMapfromKey (inclusive) and toKey (exclusive).
Neither key has to appear in this dated map. The returned map is a fully functional
dated sorted map that is closely tied to this map. Changes to either
will be reflected in the other. Any attempt to add a key outside the
specified key range will throw an IllegalArgumentException.
subMap in interface DatedSortedMap<K,V,D>fromKey - lower bound of the keys of the returned map (inclusive)toKey - upper bound of the keys of the returned map (exclusive)
fromKey
(inclusive) to toKey (exclusive)public DatedSortedMap<K,V,D> tailMap(K fromKey)
DatedSortedMapfromKey. The key fromKey does not have to appear
in this dated map. The returned map is a fully functional dated sorted
map that is closely tied to this map. Changes to either will be reflected
in the other. Any attempt to add a key less than fromKey will
throw an IllegalArgumentException.
tailMap in interface DatedSortedMap<K,V,D>fromKey - lower bound of the keys of the returned map (inclusive)
|
Side of Software Dated Collections Library 2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||