|
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.AbstractDatedObject<D> sos.dated.util.AbstractDatedCollection<E,D> sos.dated.util.AbstractDatedList<E,D> sos.dated.util.ArrayListByDate<E,D>
E
- the type of elements maintained by this dated listD
- the type of dates used by this dated listpublic class ArrayListByDate<E,D>
An implementation of DatedList
that can efficiently iterate through the list of
elements at a given date by maintaining a java.util.ArrayList
at each date.
The following illustration shows a conceptual view of a small ArrayListByDate
where the "dates" are integers and the elements are characters:
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 list with a call to
DatedCollections.synchronizedDatedList
.
ArrayListByElement
,
DatedList
,
DatedCollections.synchronizedDatedList(DatedList)
Constructor Summary | |
---|---|
ArrayListByDate()
Creates an empty ArrayListByDate . |
|
ArrayListByDate(DatedCollection<? extends E,D> datedCollection)
Creates an ArrayListByDate initialized with the elements
of datedCollection . |
Method Summary | |
---|---|
Dates<D> |
add(E value,
D from,
D to)
Adds the specified element to this dated collection for the specified date range (optional operation). |
void |
add(int index,
E value,
D from,
D to)
Inserts an element into this dated list for a specified date range (optional operation). |
void |
clear(D from,
D to)
Removes all elements from this dated collection for the specified dates (optional operation). |
java.lang.Object |
clone()
Creates and returns a shallow copy of this object. |
protected java.util.List<E> |
copyList(java.util.List<E> list)
Creates and returns a copy of the specified list. |
protected java.util.List<E> |
createList()
Creates and returns a new empty list to hold the elements for a date range. |
DateIterator<D> |
dateIterator(D at)
Returns an iterator of the date ranges of when this dated object has changed, starting at the range that contains the specified date. |
E |
get(int index,
D at)
Retrieves the element at the specified position on the specified date. |
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. |
int |
size(D at)
Returns the number of elements in this dated collection at the specified date. |
Methods inherited from class sos.dated.util.AbstractDatedList |
---|
addAll, checkForComodification, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, modCount, removeRange, subList, upModCount |
Methods inherited from class sos.dated.util.AbstractDatedCollection |
---|
addAll, contains, containsAll, containsThroughout, excludesThroughout, hasSizeThroughout, isEmpty, isEmptyThroughout, remove, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class sos.dated.util.AbstractDatedObject |
---|
dateIterator, equals, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface sos.dated.util.DatedList |
---|
add, addAll, equals, get, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, set, subList |
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 |
Constructor Detail |
---|
public ArrayListByDate()
ArrayListByDate
.
public ArrayListByDate(DatedCollection<? extends E,D> datedCollection)
ArrayListByDate
initialized with the elements
of datedCollection
.
datedCollection
- collection with which to initialize the new ArrayListByDate
java.lang.NullPointerException
- if datedCollection
is null
Method Detail |
---|
public java.lang.Object clone()
AbstractDatedList
clone
method.
protected java.util.List<E> createList()
ArrayList
. Subclasses
may override this if they wish to use a different type of list, such
as an ArrayList
with an initial capacity.
protected java.util.List<E> copyList(java.util.List<E> list)
new ArrayList(list)
.
list
- list to copy
list
public Dates<D> add(E value, D from, D to)
The returned value indicates when this dated collection changed as a result of the call and is applicable only for the specified date range. It may be read-only, and it is not tied to this dated collection.
This implementation throws an UnsupportedOperationException
.
This implementation invokes add(int,Object,D,D) for each static window within the specified range, passing it the size of this list at the start of the window as given by size.
add
in interface DatedCollection<E,D>
add
in class AbstractDatedList<E,D>
value
- element to addfrom
- starting date (inclusive) at which the element should be addedto
- ending date (exclusive) at which the element should be added
java.lang.IllegalArgumentException
- if from
does not precede to
or if some property of value
prevents it from being added to this dated collection
java.lang.NullPointerException
- if from
or to
is null
or if value
is null
and this dated collection cannot hold null elementspublic void add(int index, E value, D from, D to)
AbstractDatedList
add
in interface DatedList<E,D>
add
in class AbstractDatedList<E,D>
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 insertedpublic void clear(D from, D to)
AbstractDatedList
This implementation repeatedly invokes remove
on the iterator, while iterating
through the elements at each date within the specified range.
This implementation invokes removeRange for each static window within the
specified date range, passing in the size of the list at the start of
the window, as gotten from a call to size.
clear
in interface DatedCollection<E,D>
clear
in class AbstractDatedList<E,D>
from
- starting date (inclusive) at which this dated collection should be clearedto
- ending date (exclusive) at which this dated collection should be clearedpublic DateIterator<D> dateIterator(D at)
nextFrom
returns the
same date as previousTo
.
Passing null
as the argument will return an iterator positioned
at the beginning of the sequence.
dateIterator
in interface DatedObject<D>
dateIterator
in class AbstractDatedCollection<E,D>
at
- date to position the iteration
java.lang.NullPointerException
public E get(int index, D at)
DatedList
get
in interface DatedList<E,D>
get
in class AbstractDatedList<E,D>
index
- position to retrieve an elementat
- date at which this dated list is to be queried
public DatedValue<E,D> remove(int index, D from, D to)
AbstractDatedList
UnsupportedOperationException
.
remove
in interface DatedList<E,D>
remove
in class AbstractDatedList<E,D>
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
public DatedValue<E,D> set(int index, E value, D from, D to)
AbstractDatedList
set
in interface DatedList<E,D>
set
in class AbstractDatedList<E,D>
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 setpublic int size(D at)
AbstractDatedCollection
This implementation iterates through the elements at the specified date, counting the elements as it goes.
A subclass that can determine the size of its collection more efficiently should override this method.
size
in interface DatedCollection<E,D>
size
in class AbstractDatedList<E,D>
at
- date at which this dated collection is to be queried
DatedCollection.hasSizeThroughout(int, D, D)
|
Side of Software Dated Collections Library 2.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |