|
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.AbstractDatedCollection<E,D>
sos.dated.util.AbstractDatedSet<E,D>
sos.dated.util.TreeSetByElement<E,D>
E - the type of elements maintained by this dated setD - the type of dates used by this dated setpublic class TreeSetByElement<E,D>
An implementation of DatedSet that uses a TreeMapByKey as its underlying
data structure to keep its elements in sorted order and to provide fast
indexing to elements. The following illustration shows a conceptual view of
a small TreeSetByElement where the "dates" are integers and the elements are
characters:

[1,2): {B,K,M}
[3,5): {A,B,K,M}
[5,6): {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 set with a call to DatedCollections.synchronizedDatedSet.
TreeSetByDate,
HashSetByElement,
DatedSet,
TreeMapByKey,
DatedCollections.synchronizedDatedSet(DatedSet)| Constructor Summary | |
|---|---|
TreeSetByElement()
Creates an empty TreeSetByElement that sorts its elements according
to their natural ordering. |
|
TreeSetByElement(java.util.Comparator<? super E> comparator)
Creates an empty TreeSetByElement that uses the specified
comparator to sort its elements. |
|
TreeSetByElement(DatedCollection<? extends E,D> datedCollection)
Creates a TreeSetByElement containing the elements
and date ranges of the specified dated collection, sorted by
the elements' natural ordering. |
|
TreeSetByElement(DatedSortedSet<E,D> datedSortedSet)
Creates a TreeSetByElement containing the elements
and date ranges of the specified
dated sorted set, ordered by the parameter's comparator object. |
|
| Method Summary | |
|---|---|
Dates<D> |
add(E value,
D from,
D to)
Adds the specified element to this dated collection for the specified date range. |
void |
clear(D from,
D to)
Removes all elements from this dated collection for the specified dates. |
java.lang.Object |
clone()
Creates and returns a shallow copy of this object. |
java.util.Comparator<? super E> |
comparator()
Returns the comparator used to sorted the elements of this dated set. |
boolean |
contains(java.lang.Object value,
D date)
Returns true if this dated collection contains the specified
element on the specified date. |
boolean |
containsThroughout(java.lang.Object value,
D from,
D to)
Returns true if this dated collection contains the specified
element 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. |
boolean |
excludesThroughout(java.lang.Object value,
D from,
D to)
Returns true if this dated collection does not contain the
specified element at any date within the specified date range. |
E |
first(D at)
Returns the smallest element in this dated set at the specified date. |
boolean |
hasSizeThroughout(int size,
D from,
D to)
Returns true if the number of elements in this dated collection is
greater than or equal to the specified size throughout the specified
date range. |
DatedSortedSet<E,D> |
headSet(E toElement)
Returns a view of this dated set of all elements that precede toElement. |
boolean |
isEmpty(D at)
Returns true if this dated collection contains no elements on the
specified date. |
boolean |
isEmptyThroughout(D from,
D to)
Returns true if this dated collection contains no elements
throughout the specified date range. |
Iterator<E,D> |
iterator(D at)
Returns an iterator over the elements of this dated collection at the specified date. |
E |
last(D at)
Returns the largest element in this dated set at the specified date. |
Dates<D> |
remove(java.lang.Object value,
D from,
D to)
Removes an instance of the specified element from this dated collection for the specified date range. |
int |
size(D at)
Returns the number of elements in this dated collection at the specified date. |
DatedSortedSet<E,D> |
subSet(E fromElement,
E toElement)
Returns a view of this dated set of all elements that fall between fromElement (inclusive) and toElement (exclusive). |
DatedSortedSet<E,D> |
tailSet(E fromElement)
Returns a view of this dated set of all elements greater than or equal to fromElement. |
| Methods inherited from class sos.dated.util.AbstractDatedSet |
|---|
equals, hashCode |
| Methods inherited from class sos.dated.util.AbstractDatedCollection |
|---|
addAll, containsAll, removeAll, retainAll, toArray, toArray, toString |
| 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.DatedSet |
|---|
equals, hashCode |
| Methods inherited from interface sos.dated.util.DatedCollection |
|---|
add, addAll, clear, contains, containsAll, containsThroughout, excludesThroughout, hasSizeThroughout, isEmpty, isEmptyThroughout, iterator, remove, removeAll, retainAll, size, toArray, toArray |
| Methods inherited from interface sos.dated.util.DatedObject |
|---|
dateIterator, dateIterator, equals, hashCode, toString |
| Constructor Detail |
|---|
public TreeSetByElement()
TreeSetByElement that sorts its elements according
to their natural ordering.
public TreeSetByElement(java.util.Comparator<? super E> comparator)
TreeSetByElement that uses the specified
comparator to sort its elements. If the comparator is null,
then the elements' natural ordering is used.
comparator - object to use to sort the elements (may be null)public TreeSetByElement(DatedCollection<? extends E,D> datedCollection)
TreeSetByElement containing the elements
and date ranges of the specified dated collection, sorted by
the elements' natural ordering.
datedCollection - elements and corresponding date ranges to store
in the new TreeSetByElement
java.lang.NullPointerException - if the parameter is nullpublic TreeSetByElement(DatedSortedSet<E,D> datedSortedSet)
TreeSetByElement containing the elements
and date ranges of the specified
dated sorted set, ordered by the parameter's comparator object.
datedSortedSet - elements and corresponding date ranges to store
in the new TreeSetByElement
java.lang.NullPointerException - if the parameter is null| Method Detail |
|---|
public java.lang.Object clone()
clone in class java.lang.Objectpublic java.util.Comparator<? super E> comparator()
DatedSortedSet
comparator in interface DatedSortedSet<E,D>public E first(D at)
DatedSortedSet
first in interface DatedSortedSet<E,D>at - date for which to find the smallest element
atpublic DatedSortedSet<E,D> headSet(E toElement)
DatedSortedSettoElement.
The element toElement does not have to appear in this dated set nor will it
ever appear in the returned set. The returned set is a fully functional
dated sorted set that is tied to this set. Changes to either will be reflected
in the other. Any attempt to add an element greater than or equal to
toElement will throw an IllegalArgumentException.
headSet in interface DatedSortedSet<E,D>toElement - upper bound of the elements of the returned set (exclusive)
public E last(D at)
DatedSortedSet
last in interface DatedSortedSet<E,D>at - date for which to find the largest element
at
public DatedSortedSet<E,D> subSet(E fromElement,
E toElement)
DatedSortedSetfromElement (inclusive) and toElement (exclusive).
Neither element has to appear in this dated set. The returned set is a fully functional
dated sorted set that is closely tied to this set. Changes to either
will be reflected in the other. Any attempt to add an element outside the
specified range will throw an IllegalArgumentException.
subSet in interface DatedSortedSet<E,D>fromElement - lower bound of the elements of the returned set (inclusive)toElement - upper bound of the elements of the returned set (exclusive)
fromElement
(inclusive) to toElement (exclusive)public DatedSortedSet<E,D> tailSet(E fromElement)
DatedSortedSetfromElement. The element fromElement
does not have to appear in this dated set. The returned set is a fully functional
dated sorted set that is closely tied to this set. Changes to either will be reflected
in the other. Any attempt to add an element less than fromElement will
throw an IllegalArgumentException.
tailSet in interface DatedSortedSet<E,D>fromElement - lower bound of the elements of the returned set (inclusive)
public Dates<D> add(E value,
D from,
D to)
add in interface DatedCollection<E,D>add in class AbstractDatedCollection<E,D>value - element to addfrom - starting date (inclusive) at which the element should be addedto - ending date (exclusive) at which the element should be added
java.lang.IllegalArgumentException - if from does not precede to
java.lang.NullPointerException - if from or to is null
public void clear(D from,
D to)
clear in interface DatedCollection<E,D>clear in class AbstractDatedCollection<E,D>from - starting date (inclusive) at which this dated collection should be clearedto - ending date (exclusive) at which this dated collection should be cleared
java.lang.IllegalArgumentException - if from does not precede to
java.lang.NullPointerException - if if from or to is null
public boolean contains(java.lang.Object value,
D date)
true if this dated collection contains the specified
element on the specified date.
contains in interface DatedCollection<E,D>contains in class AbstractDatedCollection<E,D>value - element whose presence is to be testeddate - date at which this collection is to be queried
true if this dated collection contains the specified element
on the specified date
java.lang.NullPointerException - if at is nullDatedCollection.containsThroughout(java.lang.Object, D, D)
public boolean containsThroughout(java.lang.Object value,
D from,
D to)
true if this dated collection contains the specified
element throughout the specified date range.
containsThroughout in interface DatedCollection<E,D>containsThroughout in class AbstractDatedCollection<E,D>value - element 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 collection contains the specified element
throughout the specified date range
java.lang.IllegalArgumentException - if from does not precede to
java.lang.NullPointerException - if from or to is nullDatedCollection.contains(java.lang.Object, D),
DatedCollection.excludesThroughout(java.lang.Object, D, D)public 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 AbstractDatedCollection<E,D>at - date to position the iteration
public boolean excludesThroughout(java.lang.Object value,
D from,
D to)
true if this dated collection does not contain the
specified element at any date within the specified date range.
excludesThroughout in interface DatedCollection<E,D>excludesThroughout in class AbstractDatedCollection<E,D>value - element 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 collection does not contain value
at any date between from and to
java.lang.IllegalArgumentException - if from does not precede to
java.lang.NullPointerException - if from or to is nullDatedCollection.containsThroughout(java.lang.Object, D, D)
public boolean hasSizeThroughout(int size,
D from,
D to)
true if the number of elements in this dated collection is
greater than or equal to the specified size throughout the specified
date range.
hasSizeThroughout in interface DatedCollection<E,D>hasSizeThroughout in class AbstractDatedCollection<E,D>size - number of elements in questionfrom - starting date (inclusive) at which the size is to be comparedto - ending date (exclusive) at which the size is to be compared
true if this dated collection has at least the specified size
throughout the specified date range.
java.lang.IllegalArgumentException - if size < 0 or if from
does not precede to
java.lang.NullPointerException - if from or to is nullDatedCollection.size(D),
DatedCollection.isEmptyThroughout(D, D)public boolean isEmpty(D at)
true if this dated collection contains no elements on the
specified date.
isEmpty in interface DatedCollection<E,D>isEmpty in class AbstractDatedCollection<E,D>at - date at which this dated collection is to be queried
true if this dated collection contains no elements on the
specified date
java.lang.NullPointerException - if at is null
public boolean isEmptyThroughout(D from,
D to)
true if this dated collection contains no elements
throughout the specified date range.
isEmptyThroughout in interface DatedCollection<E,D>isEmptyThroughout in class AbstractDatedCollection<E,D>from - starting date (inclusive) at which this dated collection is to be queriedto - ending date (exclusive) at which this dated collection is to be queried
true if this dated collection contains no elements throughout the
specified date range.
java.lang.IllegalArgumentException - if from does not precede to
java.lang.NullPointerException - if from or to is nullDatedCollection.isEmpty(D)public Iterator<E,D> iterator(D at)
UnsupportedOperationException in its remove
method because a date range is required to remove an element from
this dated collection.
iterator in interface DatedCollection<E,D>iterator in class AbstractDatedCollection<E,D>at - date at which to iterate through the elements
java.lang.NullPointerException - if at is null
public Dates<D> remove(java.lang.Object value,
D from,
D to)
remove in interface DatedCollection<E,D>remove in class AbstractDatedCollection<E,D>value - element to removefrom - starting date (inclusive) at which the element should be removedto - ending date (exclusive) at which the element should be removed
java.lang.IllegalArgumentException - if from does not precede to
java.lang.NullPointerException - if from or to is nullDatedCollection.add(E, D, D)public int size(D at)
size in interface DatedCollection<E,D>size in class AbstractDatedCollection<E,D>at - date at which this dated collection is to be queried
java.lang.NullPointerException - if at is nullDatedCollection.hasSizeThroughout(int, D, D)
|
Side of Software Dated Collections Library 2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||