|
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.ArrayListByElement<E,D>
E
- the type of elements maintained by this dated listD
- the type of dates used by this dated listpublic class ArrayListByElement<E,D>
An implementation of DatedList
that uses a single java.util.ArrayList
to
efficiently add and set values. The following illustration shows a conceptual view of
a small ArrayListByElement
where the "dates" are integers and the elements are
characters:
In the above picture, the dated list contains the following elements for the following ranges:
[1,2): [K,A,K] [3,5): [A,N,M] [5,6): [B] [6,9): [B,C]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
.
ArrayListByDate
,
DatedList
,
DatedCollections.synchronizedDatedList(DatedList)
Constructor Summary | |
---|---|
ArrayListByElement()
Creates an initially empty ArrayListByElement with a default
size for the underlying list of elements. |
|
ArrayListByElement(DatedCollection<? extends E,D> datedCollection)
Creates an ArrayListByElement initially containing the elements and date ranges
of the specified by datedCollection . |
|
ArrayListByElement(int initialCapacity)
Creates an initially empty ArrayListByElement with the specified
initial capacity for the underlying list of elements. |
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). |
java.lang.Object |
clone()
Creates and returns a shallow copy of this object. |
DateIterator<D> |
dateIterator(D date)
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 date)
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 date)
Returns the number of elements in this dated collection at the specified date. |
Methods inherited from class sos.dated.util.AbstractDatedList |
---|
add, addAll, checkForComodification, clear, 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 |
---|
addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, subList |
Methods inherited from interface sos.dated.util.DatedCollection |
---|
add, addAll, clear, contains, containsAll, containsThroughout, excludesThroughout, hasSizeThroughout, isEmpty, isEmptyThroughout, iterator, remove, removeAll, retainAll, toArray, toArray |
Methods inherited from interface sos.dated.util.DatedObject |
---|
dateIterator, equals, hashCode, toString |
Constructor Detail |
---|
public ArrayListByElement()
ArrayListByElement
with a default
size for the underlying list of elements.
public ArrayListByElement(DatedCollection<? extends E,D> datedCollection)
ArrayListByElement
initially containing the elements and date ranges
of the specified by datedCollection
.
datedCollection
- the dated collection whose elements and corresponding
date ranges are to be placed in this date list
java.lang.NullPointerException
- if datedCollection
is null
public ArrayListByElement(int initialCapacity)
ArrayListByElement
with the specified
initial capacity for the underlying list of elements.
initialCapacity
- the initial capacity for the underlying list
of elements
java.lang.IllegalArgumentException
- if the initial capacity is negativeMethod Detail |
---|
public 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 java.lang.Object clone()
AbstractDatedList
clone
method.
clone
in class AbstractDatedList<E,D>
public DateIterator<D> dateIterator(D date)
DatedObject
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>
date
- date to position the iteration
public E get(int index, D date)
DatedList
get
in interface DatedList<E,D>
get
in class AbstractDatedList<E,D>
index
- position to retrieve an elementdate
- date at which this dated list is to be queried
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 date)
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>
date
- date at which this dated collection is to be queried
DatedCollection.hasSizeThroughout(int, D, D)
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
|
Side of Software Dated Collections Library 2.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |