|
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.TreeMapByKey<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 TreeMapByKey<K,V,D>
An implementation of DatedSortedMap that uses an underlying
TreeMap to
keep all keys in sorted order and to achieve fast access to all keys.
The following illustration shows a conceptual view of
a small TreeMapByKey where the "dates" are integers, the keys are
characters, and the values are special characters:

[1,2): {(B,+),(K,$),(M,%)}
[3,5): {(A,+),(B,$),(K,+),(M,^)}
[5,6): {(K,#),(M,^)}
[6,9): {(A,@),(B,%),(K,#)}
This implementation is serializable and cloneable; however, it is not
synchronized. To use it safely in a multi-threaded situation, wrap an
instance of the dated map with a call to DatedCollections.synchronizedDatedMap.
TreeMapByDate,
HashMapByKey,
DatedMap,
DatedCollections.synchronizedDatedMap(DatedMap)| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface sos.dated.util.DatedMap |
|---|
DatedMap.Entry<K,V,D> |
| Constructor Summary | |
|---|---|
TreeMapByKey()
Creates an empty TreeMapByKey that sorts its keys
by their natural ordering. |
|
TreeMapByKey(java.util.Comparator<? super K> comparator)
Creates an empty TreeMapByKey that uses the specified
comparator to sort the keys. |
|
TreeMapByKey(DatedMap<? extends K,? extends V,D> datedMap)
Creates a TreeMapByKey containing the entries
and date ranges of the specified dated map, sorted by
the keys' natural ordering. |
|
TreeMapByKey(DatedSortedMap<K,? extends V,D> datedSortedMap)
Creates a TreeMapByKey containing the entries
and date ranges of the specified
dated sorted map, ordered by the parameter's comparator object. |
|
| Method Summary | |
|---|---|
protected void |
checkForComodification(int expectedModCount,
D date)
Throws a ConcurrentModificationException if the expected modification count does not equal the actual modification count for the specified date. |
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. |
boolean |
containsKey(java.lang.Object key,
D at)
Returns true if this dated map contains the specified key at the
specified date. |
boolean |
containsKeyThroughout(java.lang.Object key,
D from,
D to)
Returns true if this dated map contains the specified key throughout
the specified date range. |
DateIterator<D> |
dateIterator(D at)
Returns an iterator of the date ranges of when this dated object has changed, starting at the range that contains the specified date. |
DatedSet<DatedMap.Entry<K,V,D>,D> |
entrySet()
Returns a modifiable view of the mappings of this dated map. |
boolean |
excludesKeyThroughout(java.lang.Object key,
D from,
D to)
Returns true if this dated map does not contain the specified key at any date
within the specified date range. |
K |
firstKey(D at)
Returns the smallest key in this dated map at the specified date. |
DatedValue<V,D> |
get(java.lang.Object key)
Returns the values associated with the specified key for all dates. |
DatedSortedMap<K,V,D> |
headMap(K toKey)
Returns a view of this dated map of all mappings whose keys precede toKey. |
K |
lastKey(D at)
Returns the largest key in this dated map at the specified date. |
protected int |
modCount(D at)
Returns the modification count at the specified date. |
DatedValue<V,D> |
put(K key,
V value,
D from,
D to)
Associates key with value in this dated map during
the specified date range. |
DatedValue<V,D> |
remove(java.lang.Object key,
D from,
D to)
Removes any values associated with the specified key in the specified date range. |
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. |
protected void |
upModCount(D from,
D to)
Adds 1 to the modification count for the specified date range. |
| Methods inherited from class sos.dated.util.AbstractDatedMap |
|---|
clear, containsValue, containsValueThroughout, equals, excludesValueThroughout, get, hashCode, hasSizeThroughout, isEmpty, isEmptyThroughout, keySet, putAll, 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 TreeMapByKey()
TreeMapByKey that sorts its keys
by their natural ordering.
public TreeMapByKey(java.util.Comparator<? super K> comparator)
TreeMapByKey that uses the specified
comparator to sort the keys. If the comparator is null, then the
keys' natural ordering is used.
comparator - object to use to sort the keys (may be null)public TreeMapByKey(DatedMap<? extends K,? extends V,D> datedMap)
TreeMapByKey containing the entries
and date ranges of the specified dated map, sorted by
the keys' natural ordering.
datedMap - entries and corresponding date ranges to store
in the new TreeMapByKey
java.lang.NullPointerException - if the parameter is nullpublic TreeMapByKey(DatedSortedMap<K,? extends V,D> datedSortedMap)
TreeMapByKey containing the entries
and date ranges of the specified
dated sorted map, ordered by the parameter's comparator object.
datedSortedMap - entries and corresponding date ranges to store
in the new TreeMapByKey
java.lang.NullPointerException - if the parameter is null| Method Detail |
|---|
public java.util.Comparator<? super K> comparator()
DatedSortedMap
comparator in interface DatedSortedMap<K,V,D>public java.lang.Object clone()
public K firstKey(D at)
DatedSortedMap
firstKey in interface DatedSortedMap<K,V,D>at - 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 at)
DatedSortedMap
lastKey in interface DatedSortedMap<K,V,D>at - 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)
protected void checkForComodification(int expectedModCount,
D date)
expectedModCount - the caller's expected modification countdate - the date in question
java.util.ConcurrentModificationException - if the expected modification
count does not equal the actual modification count for the specified date
public boolean containsKey(java.lang.Object key,
D at)
true if this dated map contains the specified key at the
specified date.
containsKey in interface DatedMap<K,V,D>containsKey in class AbstractDatedMap<K,V,D>key - key whose presence is to be testedat - date at which this map is to be queried
true if this dated map contains the specified key at the
specified date
java.lang.NullPointerException - if at is null
public boolean containsKeyThroughout(java.lang.Object key,
D from,
D to)
true if this dated map contains the specified key throughout
the specified date range.
containsKeyThroughout in interface DatedMap<K,V,D>containsKeyThroughout in class AbstractDatedMap<K,V,D>key - key whose presence is to be testedfrom - starting date (inclusive) at which containment should be testedto - ending date (exclusive) at which containment should be tested
true if this dated map contains the specified key
throughout the specified date range
java.lang.IllegalArgumentException - if from does not precede to
java.lang.NullPointerException - if from or to is nullpublic DateIterator<D> dateIterator(D at)
DatedObjectnextFrom returns the
same date as previousTo.
Passing null as the argument will return an iterator positioned
at the beginning of the sequence.
dateIterator in interface DatedObject<D>dateIterator in class AbstractDatedObject<D>at - date to position the iteration
public boolean excludesKeyThroughout(java.lang.Object key,
D from,
D to)
true if this dated map does not contain the specified key at any date
within the specified date range.
excludesKeyThroughout in interface DatedMap<K,V,D>excludesKeyThroughout in class AbstractDatedMap<K,V,D>key - key whose presence is to be testedfrom - starting date (inclusive) at which exclusion should be testedto - ending date (exclusive) at which exclusion should be tested
true if this dated map does not contain key key
between from and to
java.lang.IllegalArgumentException - if from does not precede to
java.lang.NullPointerException - if if from or to is nullpublic DatedValue<V,D> get(java.lang.Object key)
get in interface DatedMap<K,V,D>get in class AbstractDatedMap<K,V,D>key - key whose values are to be returned
keyprotected int modCount(D at)
at. If assertions are not enabled, the returned
value is always zero.
at - date to request the modification count
public DatedValue<V,D> put(K key,
V value,
D from,
D to)
key with value in this dated map during
the specified date range.
put in interface DatedMap<K,V,D>put in class AbstractDatedMap<K,V,D>key - key to put in this dated mapvalue - value to map to the keyfrom - starting date (inclusive) at which to put the mappingto - ending date (exclusive) at which to put the mapping
java.lang.IllegalArgumentException - if from does not precede to
java.lang.NullPointerException - if from or to is null
protected void upModCount(D from,
D to)
from - starting date (inclusive) for which to increment the countto - ending date (exclusive) for which to increment the countpublic DatedSet<DatedMap.Entry<K,V,D>,D> entrySet()
entrySet in interface DatedMap<K,V,D>entrySet in class AbstractDatedMap<K,V,D>
public DatedValue<V,D> remove(java.lang.Object key,
D from,
D to)
remove in interface DatedMap<K,V,D>remove in class AbstractDatedMap<K,V,D>key - key indicating which mapping to removefrom - starting date (inclusive) at which to remove the mappingto - ending date (exclusive) at which to remove the mapping
java.lang.IllegalArgumentException - if from does not precede to
java.lang.NullPointerException - if from or to is null
|
Side of Software Dated Collections Library 2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||