sos.dated.util
Interface DatedSet
- All Superinterfaces:
- DatedCollection, DatedObject
- All Known Subinterfaces:
- DatedSortedSet
- All Known Implementing Classes:
- AbstractDatedSet, sos.dated.util.AbstractMapBackedSet, HashSetByDate, HashSetByElement, TreeSetByDate, TreeSetByElement
- public interface DatedSet
- extends DatedCollection
A set of elements over time. A dated set is a dated collection with the additional
requirement that an element appear at most once at a given
date. This interface is based on the interface java.util.Set.
The following table compares the efficiencies of the four implementations
in this package. Each cell is the average big-Oh notation, where T denotes the
number of dates in the set and N denotes the number of elements at any given
date.
| HashSetByDate | HashSetByKey | TreeSetByDate | TreeSetByKey |
| add | T*N | T | T*N | T+log(N) |
| clear | T | T*N | T | T*N |
| contains | log(T) | log(T) | log(T)+log(N) | log(T)+log(N) |
| containsThroughout | T | T | T*log(N) | T+log(N) |
| dateIterator | log(T) | T*N | log(T) | T*N |
| hashCode | T*N | T*N | T*N | T*N |
| hashCode(d) | log(T)+N | log(T)*N | log(T)+N | log(T)*N |
| remove | T*N | T | T*N | T+log(N) |
| size | log(T) | log(T) | log(T) | log(T) |
This interface does not extend java.util.Set directly
because at least one date is needed. To make a dated set appear
like a non-dated set, use Adapters.asSet(DatedSet,Date).
Similarly, to treat a non-dated set as dated, use
Adapters.asDatedSet(Set,Date,Date).
- Since:
- 1.0
- See Also:
HashSetByDate,
HashSetByElement,
TreeSetByDate,
TreeSetByElement,
Adapters.asSet(DatedSet,Date),
Adapters.asDatedSet(Set,Date,Date)
|
Method Summary |
boolean |
equals(java.util.Date date,
DatedObject obj,
java.util.Date objDate)
Indicates if this dated set at date is equal to
obj at objDate. |
int |
hashCode(java.util.Date date)
Returns a hash code value of this dated set at the specified date. |
| 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 |
equals
public boolean equals(java.util.Date date,
DatedObject obj,
java.util.Date objDate)
- Indicates if this dated set at
date is equal to
obj at objDate.
Two sets are equivalent at the specified dates if their sizes
are equal and one set contains all elements of the other set.
- Specified by:
equals in interface DatedObject
- Parameters:
date - date at which this object should be testedobj - the other dated object to be compared toobjDate - the date of the other dated object
- Returns:
true if this dated set at date equals
another dated object at objDate
- Throws:
java.lang.NullPointerException - if any argument is null
hashCode
public int hashCode(java.util.Date date)
- Returns a hash code value of this dated set at the specified date.
The hash code of a
DatedSet at a date is calculated the same way as in
hashCode of java.util.Set.
- Specified by:
hashCode in interface DatedObject
- Parameters:
date - date to which the value should correspond
- Returns:
- the hash code value of this dated object at the specified date
- Throws:
java.lang.NullPointerException - if date is null
Copyright 2003 Side of Software (SOS). All rights reserved.