|
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.Object sos.dated.util.AbstractDates<D> sos.dated.util.TreeDates<D>
D
- the type of dates used in this seriespublic class TreeDates<D>
An implementation of Dates
that uses a Red-Black tree to achieve logarithmic
insertions and deletions. The following illustration shows a conceptual view of
a small TreeDates
where the "dates" are integers:
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.synchronizedDates
.
Dates
,
DatedCollections.synchronizedDates(Dates)
Constructor Summary | |
---|---|
TreeDates()
Creates a TreeDates with no dates. |
|
TreeDates(Dates<D> dates)
Creates a TreeDates initialized with the ranges of dates. |
Method Summary | |
---|---|
Dates<D> |
addAll(Dates<D> dates)
Adds all date ranges given by dates to this series of dates. |
Dates<D> |
addRange(D from,
D to)
Adds a date range to this series of dates. |
void |
clear()
Removes all date ranges from this series of dates. |
java.lang.Object |
clone()
Creates and returns a shallow copy of this object. |
void |
complement(D from,
D to)
Modifies this Dates object so that it contains only the ranges not
currently in this Dates object. |
DateIterator<D> |
dateIterator(D at)
Returns an iterator over the date ranges, starting at the range that contains the specified date. |
boolean |
includes(D at)
Indicates if a date range in this series contains the specified date. |
boolean |
isEmpty()
Indicates if this series of dates is empty. |
Dates<D> |
removeAll(Dates<D> dates)
Removes all dates ranges given by dates from this series of dates. |
Dates<D> |
removeRange(D from,
D to)
Removes the specified range from this series of dates. |
Dates<D> |
retainAll(Dates<D> dates)
Removes all but the date ranges given by dates from this series of dates. |
Methods inherited from class sos.dated.util.AbstractDates |
---|
dateIterator, equals, excludesAll, excludesRange, hashCode, includesAll, includesRange, size, toDateArray, toDateArray, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface sos.dated.util.Dates |
---|
dateIterator, equals, excludesAll, excludesRange, hashCode, includesAll, includesRange, size, toDateArray, toDateArray |
Constructor Detail |
---|
public TreeDates()
TreeDates
with no dates.
public TreeDates(Dates<D> dates)
TreeDates
initialized with the ranges of dates.
dates
- date ranges for which to initialize this new TreeDates
java.lang.NullPointerException
- if dates
is null
Method Detail |
---|
public Dates<D> addAll(Dates<D> dates)
dates
to this series of dates.
addAll
in interface Dates<D>
addAll
in class AbstractDates<D>
dates
- series of dates to be added
java.lang.NullPointerException
- if dates
is null
public Dates<D> addRange(D from, D to)
addRange
in interface Dates<D>
addRange
in class AbstractDates<D>
from
- start of the date range, inclusiveto
- end of the date range, exclusive
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if from
or to
is null
public void clear()
clear
in interface Dates<D>
clear
in class AbstractDates<D>
public java.lang.Object clone()
clone
in class java.lang.Object
public void complement(D from, D to)
Dates
object so that it contains only the ranges not
currently in this Dates
object.
complement
in interface Dates<D>
complement
in class AbstractDates<D>
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if from
or to
is null
public DateIterator<D> dateIterator(D at)
Dates
null
as the argument will return an iterator positioned
at the beginning of the series.
dateIterator
in interface Dates<D>
dateIterator
in class AbstractDates<D>
at
- date to position the iteration
public boolean includes(D at)
includes
in interface Dates<D>
includes
in class AbstractDates<D>
at
- date to test for inclusion
true
if this series of dates contains the specified date
java.lang.NullPointerException
- if at
is null
public boolean isEmpty()
isEmpty
in interface Dates<D>
isEmpty
in class AbstractDates<D>
true
if no date ranges exist in this seriespublic Dates<D> removeAll(Dates<D> dates)
removeAll
in interface Dates<D>
removeAll
in class AbstractDates<D>
dates
- date ranges to be removed
java.lang.NullPointerException
- if dates
is null
public Dates<D> removeRange(D from, D to)
removeRange
in interface Dates<D>
removeRange
in class AbstractDates<D>
from
- start of date range to remove (inclusive)to
- end of date range to remove (exclusive)
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if from
or to
is null
public Dates<D> retainAll(Dates<D> dates)
dates
from this series of dates.
retainAll
in interface Dates<D>
retainAll
in class AbstractDates<D>
dates
- date ranges to retain
java.lang.NullPointerException
- if dates
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 |