Side of Software
Dated Collections Library 2.0

sos.dated.util
Interface DatedSet<E,D>

Type Parameters:
E - the type of elements maintained by this dated set
D - the type of dates used by this dated set
All Superinterfaces:
DatedCollection<E,D>, DatedObject<D>
All Known Subinterfaces:
DatedSortedSet<E,D>
All Known Implementing Classes:
AbstractDatedSet, HashSetByDate, HashSetByElement, LinkedHashSetByDate, TreeSetByDate, TreeSetByElement

public interface DatedSet<E,D>
extends DatedCollection<E,D>

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,Object), Adapters.asDatedSet(Set,Object,Object)

Method Summary
 boolean equals(D at, DatedObject<D> obj, D objAt)
          Indicates if this dated set at date is equal to obj at objDate.
 int hashCode(D at)
          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

boolean equals(D at,
               DatedObject<D> obj,
               D objAt)
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<D>
Parameters:
at - date at which this object should be tested
obj - the other dated object to be compared to
objAt - 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

int hashCode(D at)
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<D>
Parameters:
at - 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

Side of Software
Dated Collections Library 2.0

Copyright 2003-09 Side of Software (SOS). All rights reserved.