|
Side of Software Dated Collections Library 2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
E - the type of elements maintained by this dated listD - the type of dates used by this dated listpublic interface DatedList<E,D>
A list of elements over time.
The following table compares the efficiencies of the two implementations
in this package. Each cell is the average big-Oh notation, where T denotes the
number of dates in the map and N denotes the number of elements at any given
date.
ArrayListByDate ArrayListByElement add T*N T (amortized) add(i) T*N T*N clear T T*N contains log(T)+N log(T)*N containsThroughout T*N T*N dateIterator log(T) T*N get log(T) log(T) hashCode T*N T*N hashCode(d) log(T)+N log(T)*N indexOf log(T)+N log(T)*N iterator log(T) log(T) lastIndexOf log(T)+N log(T)*N listIterator log(T) log(T) remove T*N T*N remove(i) T*N T*N set T*N T size log(T) log(T)
The interface is based on the interface
java.util.List. This interface does not extend java.util.List directly
because at least one date is needed. To make a dated list appear
like a non-dated list, use Adapters.asList(DatedList,Date).
Similarly, to treat a non-dated collection as dated, use
Adapters.asDatedList(List,Date,Date).
ArrayListByDate,
ArrayListByElement,
Adapters.asList(DatedList,Object),
Adapters.asDatedList(List,Object,Object)| Method Summary | |
|---|---|
void |
add(int index,
E value,
D from,
D to)
Inserts an element into this dated list for a specified date range (optional operation). |
Dates<D> |
addAll(int index,
DatedCollection<? extends E,D> datedCollection)
Inserts an entire dated collection into this dated list at the specified index (optional operation). |
boolean |
equals(D at,
DatedObject<D> obj,
D objAt)
Indicates if this dated object at at is equal to
obj at objAt. |
E |
get(int index,
D at)
Retrieves the element at the specified position on the specified date. |
int |
hashCode(D at)
Returns a hash code value of this dated list at the specified date. |
int |
indexOf(java.lang.Object value,
D at)
Returns the position of the first occurrence of the specified element in this list at the specified date, or -1 if this dated list does not contain the element at that date. |
int |
lastIndexOf(java.lang.Object value,
D at)
Returns the position of the last occurrence of the specified element in this list at the specified date, or -1 if this dated list does not contain the element at that date. |
ListIterator<E,D> |
listIterator(D at)
Returns a list iterator over the elements of this dated list at the specified date. |
ListIterator<E,D> |
listIterator(int index,
D at)
Returns a list iterator over the elements of this dated list at the specified date, starting at the specified index. |
DatedValue<E,D> |
remove(int index,
D from,
D to)
Removes from this dated list the element at the specified position for the specified date range (optional operation). |
DatedValue<E,D> |
set(int index,
E value,
D from,
D to)
Replaces the element at the specified position with the specified element for the specified date range. |
DatedList<E,D> |
subList(int fromIndex,
int toIndex)
Returns a view of this dated list restricted to the range fromIndex,
inclusive, to toIndex, exclusive. |
| 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 |
|---|
void add(int index,
E value,
D from,
D to)
index - position to insert the elementvalue - element to insertfrom - starting date (inclusive) at which the element should be insertedto - ending date (exclusive) at which the element should be inserted
java.lang.ClassCastException - if the underlying type of value prevents it from
being added to this dated list
java.lang.IllegalArgumentException - if from does not precede to
or if some property of value prevents it from being added to this dated list
java.lang.IndexOutOfBoundsException - if index < 0 || index > size( d )
where d is a date between from and to
java.lang.NullPointerException - if from or to is null
or if value is null and this dated list cannot hold null elements
java.lang.UnsupportedOperationException - if this dated list does not support add
Dates<D> addAll(int index,
DatedCollection<? extends E,D> datedCollection)
index - index at which to insert the dated collectiondatedCollection - collection to insert into this dated list
java.lang.ClassCastException - if the type of an element of datedCollection prevents it from
being added to this dated list
java.lang.IllegalArgumentException - if some property of an element of datedCollection
prevents it from being added to this dated list
java.lang.IndexOutOfBoundsException - if index < 0 || index > size( d )
where d is a date when elements exist in datedCollection
java.lang.NullPointerException - if datedCollection is null
or if an element of datedCollection is null and this dated list
cannot hold null elements
java.lang.UnsupportedOperationException - if this dated list does not support addAll
boolean equals(D at,
DatedObject<D> obj,
D objAt)
DatedObjectat is equal to
obj at objAt.
equals in interface DatedObject<D>at - date at which this object should be testedobj - the other dated object to be compared toobjAt - the date of the other dated object
true if this dated object at at equals
another dated object at objAt
E get(int index,
D at)
index - position to retrieve an elementat - date at which this dated list is to be queried
java.lang.IndexOutOfBoundsException - if index < 0 || index >= size( at )
java.lang.NullPointerException - if at is nullint hashCode(D at)
DatedList at a date is calculated the same way as in
hashCode of java.util.List.
hashCode in interface DatedObject<D>at - date to which the value should correspond
java.lang.NullPointerException - if at is null
int indexOf(java.lang.Object value,
D at)
value - element whose presence is to be testedat - date to search for the element
java.lang.NullPointerException - if at is null
int lastIndexOf(java.lang.Object value,
D at)
value - element whose presence is to be testedat - date to search for the element
java.lang.NullPointerException - if at is nullListIterator<E,D> listIterator(D at)
at - date at which to iterate over the elements of this dated list
java.lang.NullPointerException - if at is null
ListIterator<E,D> listIterator(int index,
D at)
index - position at which to start the iterationat - date at which to iterate over the elements of this dated list
java.lang.IndexOutOfBoundsException - if index < 0 || index >= size( at )
java.lang.NullPointerException - if at is null
DatedValue<E,D> remove(int index,
D from,
D to)
index - position at which to start the iterationfrom - 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.IndexOutOfBoundsException - if index < 0 || index >= size( d )
where d is a date within the specified range
java.lang.NullPointerException - if from or to is null
java.lang.UnsupportedOperationException - if this dated list does not support remove
DatedValue<E,D> set(int index,
E value,
D from,
D to)
index - position of the element to replacevalue - element to place in this listfrom - starting date (inclusive) at which the position should be setto - ending date (exclusive) at which the position should be set
java.lang.ClassCastException - if the underlying type of value prevents it from
being added to this dated list
java.lang.IllegalArgumentException - if from does not precede to
or if some property of value prevents it from being added to this dated list
java.lang.IndexOutOfBoundsException - if this dated list does not contain index + 1
elements throughout the specified date range
java.lang.NullPointerException - if from or to is null
or if value is null and this dated list cannot hold null elements
java.lang.UnsupportedOperationException - if this dated list does not support set
DatedList<E,D> subList(int fromIndex,
int toIndex)
fromIndex,
inclusive, to toIndex, exclusive. Changes made to the returned
sub-list are reflected in the master list, and vice versa.
For the date ranges where the interval [fromIndex,toIndex)
is not present in this dated list, some sub-list operations will throw an
IllegalArgumentException. For example, consider the
following code, where d0, d1, etc. are consecutive dates:
DatedList list = new ArrayListByDate();
list.add( "A", d0, d2 );
list.add( "B", d1, d2 );
DatedList subList = list.subList( 1, 2 );
subList.add( "C", d1, d2 ); // successful
subList.add( "C", d0, d2 ); // fails because list does not have
// 2 elements at d0
int size = subList.size( d0 ); // returns 0
size = subList.size( d1 ); // returns 1
subList.get( 0, d0 ); // fails
Therefore, it is only safe to use the sub-list during date ranges
where the interval [fromIndex,toIndex) exists in this list.
fromIndex - starting position of the returned view (inclusive)toIndex - ending position of the returned view (exclusive)
|
Side of Software Dated Collections Library 2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||