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.

HashSetByDateHashSetByKeyTreeSetByDateTreeSetByKey
addT*NTT*NT+log(N)
clearTT*NTT*N
containslog(T)log(T)log(T)+log(N)log(T)+log(N)
containsThroughoutTTT*log(N)T+log(N)
dateIteratorlog(T)T*Nlog(T)T*N
hashCodeT*NT*NT*NT*N
hashCode(d)log(T)+Nlog(T)*Nlog(T)+Nlog(T)*N
removeT*NTT*NT+log(N)
sizelog(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)

Field Summary
 
Fields inherited from interface sos.dated.util.DatedObject
MAX_DATE, MIN_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
 
Methods inherited from interface sos.dated.util.DatedObject
dateIterator, dateIterator, equals, hashCode, toString
 

Method Detail

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 tested
obj - the other dated object to be compared to
objDate - 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.