|
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.DatedCollections
public class DatedCollections
Views and algorithms that act on dated collections. This class
is the equivalent to java.util.Collections
that works on dated collections.
Specifically, it provides synchronized equivalents of the collections with the methods
synchronizedDatedList(DatedList)
synchronizedDatedMap(DatedMap)
synchronizedDatedSet(DatedSet)
synchronizedDatedSortedSet(DatedSortedSet)
synchronizedDatedSortedMap(DatedSortedMap)
synchronizedDatedValue(DatedValue)
unmodifiableDatedList(DatedList)
unmodifiableDatedMap(DatedMap)
unmodifiableDatedSet(DatedSet)
unmodifiableDatedSortedSet(DatedSortedSet)
unmodifiableDatedSortedMap(DatedSortedMap)
unmodifiableDatedValue(DatedValue)
checkedDatedList(DatedList)
checkedDatedMap(DatedMap)
checkedDatedSet(DatedSet)
checkedDatedSortedSet(DatedSortedSet)
checkedDatedSortedMap(DatedSortedMap)
checkedDatedValue(DatedValue)
DatedCollection
,
DatedSet
,
DatedList
,
DatedMap
,
Adapters
Nested Class Summary | |
---|---|
static interface |
DatedCollections.Action<D>
Action to perform on a dated object at a period when it does not change. |
Field Summary | |
---|---|
static DatedList |
EMPTY_DATED_LIST
An empty and immutable dated list. |
static DatedMap |
EMPTY_DATED_MAP
An empty and immutable dated map. |
static DatedSet |
EMPTY_DATED_SET
An empty and immutable dated set. |
static Dates |
EMPTY_DATES
An empty and immutable series of dates. |
static DatedValue |
NULL_DATED_VALUE
An immutable dated value with only null values. |
Method Summary | ||
---|---|---|
static
|
addAll(DatedCollection<? super E,D> datedCollection,
D from,
D to,
E... elements)
Adds the specified elements to a dated collection for a given date range. |
|
static
|
applyAtDates(DatedObject<D> datedObject,
D from,
D to,
DatedCollections.Action<D> action)
Performs the specified destructive action on the specified dated object within the specified date range. |
|
static
|
binarySearch(DatedList<? extends java.lang.Comparable<? super E>,D> datedList,
E key,
D at)
Searches for the specified key in the specified ordered list at the specified date, returning the index of the key or the index of where the key would be inserted times negative one minus one. |
|
static
|
binarySearch(DatedList<? extends E,D> datedList,
E key,
java.util.Comparator<? super E> comparator,
D at)
Searches for the specified key in the specified ordered list at the specified date, using the specified comparator, and returning the index of the key or the index of where the key would be inserted times negative one minus one. |
|
static
|
checkedDatedCollection(DatedCollection<E,D> datedCollection,
java.lang.Class<E> type)
Wraps a dated collection with one that requires elements to be of a given type. |
|
static
|
checkedDatedList(DatedList<E,D> datedList,
java.lang.Class<E> type)
Wraps a dated list with one that requires elements to be of a given type. |
|
static
|
checkedDatedMap(DatedMap<K,V,D> datedMap,
java.lang.Class<K> keyType,
java.lang.Class<V> valueType)
Wraps a dated map with one that requires keys and values to be of a given type. |
|
static
|
checkedDatedSet(DatedSet<E,D> datedSet,
java.lang.Class<E> type)
Wraps a dated set with one that requires elements to be of a given type. |
|
static
|
checkedDatedSortedMap(DatedSortedMap<K,V,D> datedSortedMap,
java.lang.Class<K> keyType,
java.lang.Class<V> valueType)
Wraps a dated sorted map with one that requires keys and values to be of a given type. |
|
static
|
checkedDatedSortedSet(DatedSortedSet<E,D> datedSortedSet,
java.lang.Class<E> type)
Wraps a dated sorted set with one that requires elements to be of a given type. |
|
static
|
checkedDatedValue(DatedValue<E,D> datedValue,
java.lang.Class<E> type)
Wraps a dated value with one that requires values to be of a given type. |
|
static
|
copy(DatedList<? super E,D> datedList,
java.util.List<? extends E> src,
D from,
D to)
Copies the elements of src into datedList for the specified date range. |
|
static
|
disjoint(DatedCollection<?,D> datedCollection1,
DatedCollection<?,D> datedCollection2,
D at)
Returns true if the two specified dated collections have no elements in common at the given date. |
|
static
|
emptyDatedList()
Returns the empty dated list in a type-safe fashion. |
|
static
|
emptyDatedMap()
Returns the empty dated map in a type-safe fashion. |
|
static
|
emptyDatedSet()
Returns the empty dated set in a type-safe fashion. |
|
static
|
emptyDates()
Returns the empty dates in a type-safe fashion. |
|
static
|
fill(DatedList<? super E,D> datedList,
E obj,
D from,
D to)
Replaces all elements of the specified dated list with the specified object for the specified date range. |
|
static
|
frequency(DatedCollection<?,D> datedCollection,
java.lang.Object object,
D at)
Returns the number of occurrences of an object in the specified dated collection at a given date. |
|
static
|
indexOfSubList(DatedList<?,D> datedList,
java.util.List<?> target,
D at)
Returns the index of the first occurrence of target in the specified dated list at the specified date, or -1 if it never occurs. |
|
static
|
lastIndexOfSubList(DatedList<?,D> datedList,
java.util.List<?> target,
D at)
Returns the index of the last occurrence of target in the specified dated list at the specified date, or -1 if it never occurs. |
|
static
|
max(DatedCollection<E,D> datedCollection,
java.util.Comparator<? super E> comparator,
D at)
Returns the maximum value in the specified dated collection at the specified date, according to the specified comparator. |
|
static
|
max(DatedCollection<E,D> datedCollection,
D at)
Returns the maximum value (according to the natural ordering) in the specified dated collection at the specified date. |
|
static
|
min(DatedCollection<E,D> datedCollection,
java.util.Comparator<? super E> comparator,
D at)
Returns the maximum value in the specified dated collection at the specified date, according to the specified comparator. |
|
static
|
min(DatedCollection<E,D> datedCollection,
D at)
Returns the minimum value (according to the natural ordering) in the specified dated collection at the specified date. |
|
static
|
nCopies(int n,
E o,
D from,
D to)
Returns an unmodifiable dated list containing exactly n copies of the specified object during the specified date range. |
|
static
|
nullDatedValue()
Returns the null dated value in a type-safe fashion. |
|
static
|
queryAtDates(DatedObject<D> datedObject,
D from,
D to,
DatedCollections.Action<D> action)
Performs the specified non-destructive action on the specified dated object within the specified date range. |
|
static
|
replaceAll(DatedList<E,D> datedList,
E oldVal,
E newVal,
D from,
D to)
Replaces all occurrences of oldVal with newVal in the specified list throughout the specified date range. |
|
static
|
reverse(DatedList<E,D> datedList,
D from,
D to)
Reverses the elements of the specified dated list in the specified date range. |
|
static
|
rotate(DatedList<E,D> datedList,
int distance,
D from,
D to)
Shifts the elements of the specified dated list in the specified date range the specified distance. |
|
static
|
shuffle(DatedList<E,D> datedList,
D from,
D to)
Randomly rearranges the elements of the specified dated list in the specified date range The routine uses an internal random number generator. |
|
static
|
shuffle(DatedList<E,D> datedList,
java.util.Random rnd,
D from,
D to)
Randomly rearranges the elements of the specified dated list in the specified date range, using the specified random number generator. |
|
static
|
singletonDatedList(E o,
D from,
D to)
Returns an unmodifiable dated list containing only the specified object during the specified date range. |
|
static
|
singletonDatedMap(K key,
V value,
D from,
D to)
Returns an unmodifiable dated map containing only the mapping of key to value during the specified date range. |
|
static
|
singletonDatedSet(E o,
D from,
D to)
Returns an unmodifiable dated set containing only the specified object during the specified date range. |
|
static
|
sort(DatedList<E,D> datedList,
java.util.Comparator<? super E> comparator,
D from,
D to)
Sorts the elements of the specified dated list in the specified date range in ascending order, using the specified comparator. |
|
static
|
sort(DatedList<E,D> datedList,
D from,
D to)
Sorts the elements of the specified dated list in the specified date range in ascending order. |
|
static
|
swap(DatedList<?,D> datedList,
int i,
int j,
D from,
D to)
Exchanges the elements at indices i and j in the specified list at the specified date. |
|
static
|
synchronizedDatedCollection(DatedCollection<E,D> datedCollection)
Returns a synchronized, or thread-safe, view of a dated collection. |
|
static
|
synchronizedDatedList(DatedList<E,D> datedList)
Returns a synchronized, or thread-safe, view of a dated list. |
|
static
|
synchronizedDatedMap(DatedMap<K,V,D> datedMap)
Returns a synchronized, or thread-safe, view of a dated map. |
|
static
|
synchronizedDatedObject(DatedObject<D> datedObject)
Returns a synchronized, or thread-safe, view of a dated object. |
|
static
|
synchronizedDatedSet(DatedSet<E,D> datedSet)
Returns a synchronized, or thread-safe, view of a dated set. |
|
static
|
synchronizedDatedSortedMap(DatedSortedMap<K,V,D> datedSortedMap)
Returns a synchronized, or thread-safe, view of a dated sorted map. |
|
static
|
synchronizedDatedSortedSet(DatedSortedSet<E,D> datedSortedSet)
Returns a synchronized, or thread-safe, view of a dated sorted set. |
|
static
|
synchronizedDatedValue(DatedValue<E,D> datedValue)
Returns a synchronized, or thread-safe, view of a dated value. |
|
static
|
synchronizedDates(Dates<D> dates)
Returns a synchronized, or thread-safe, view of a series of date ranges. |
|
static
|
unmodifiableDatedCollection(DatedCollection<? extends E,D> datedCollection)
Returns an unmodifiable view of a dated collection. |
|
static
|
unmodifiableDatedList(DatedList<? extends E,D> datedList)
Returns an unmodifiable view of a dated list. |
|
static
|
unmodifiableDatedMap(DatedMap<? extends K,? extends V,D> datedMap)
Returns an unmodifiable view of a dated map. |
|
static
|
unmodifiableDatedSet(DatedSet<? extends E,D> datedSet)
Returns an unmodifiable view of a dated set. |
|
static
|
unmodifiableDatedSortedMap(DatedSortedMap<K,? extends V,D> datedSortedMap)
Returns an unmodifiable view of a dated sorted map. |
|
static
|
unmodifiableDatedSortedSet(DatedSortedSet<E,D> datedSortedSet)
Returns an unmodifiable view of a dated sorted set. |
|
static
|
unmodifiableDatedValue(DatedValue<? extends E,D> datedValue)
Returns an unmodifiable view of a dated value. |
|
static
|
unmodifiableDates(Dates<D> dates)
Returns an unmodifiable view of a series of dates. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Dates EMPTY_DATES
Dates
object is serializable and resolves to this same object when
deserialized.
public static final DatedList EMPTY_DATED_LIST
public static final DatedSet EMPTY_DATED_SET
public static final DatedMap EMPTY_DATED_MAP
public static final DatedValue NULL_DATED_VALUE
null
values.
This dated value is serializable and resolves to this same object when
deserialized.
Method Detail |
---|
public static <D> void applyAtDates(DatedObject<D> datedObject, D from, D to, DatedCollections.Action<D> action)
from
and to
in
datedObject
. Then it invokes the
action's perform
method for the discovered ranges. A change to the dated
object during perform
does not alter the iteration over dates in any way.
datedObject
- target of actionfrom
- start date of range (inclusive) to perform actionto
- end date of range (exclusive) to perform actionaction
- destructive action to perform on datedObject
between
from
and to
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if any argument is null
queryAtDates(sos.dated.util.DatedObject, D, D, sos.dated.util.DatedCollections.Action)
public static <D> void queryAtDates(DatedObject<D> datedObject, D from, D to, DatedCollections.Action<D> action)
datedObject
- target of actionfrom
- start date of range (inclusive) to perform actionto
- end date of range (exclusive) to perform actionaction
- non-destructive action to perform on datedObject between
from and to
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if any argument is null
applyAtDates(sos.dated.util.DatedObject, D, D, sos.dated.util.DatedCollections.Action)
public static final <D> Dates<D> emptyDates()
EMPTY_DATES
public static final <E,D> DatedList<E,D> emptyDatedList()
EMPTY_DATED_LIST
public static final <K,V,D> DatedMap<K,V,D> emptyDatedMap()
EMPTY_DATED_MAP
public static final <E,D> DatedSet<E,D> emptyDatedSet()
EMPTY_DATED_SET
public static final <E,D> DatedValue<E,D> nullDatedValue()
NULL_DATED_VALUE
public static <D> Dates<D> unmodifiableDates(Dates<D> dates)
In this implementation, the returned Dates
object "wraps"
the specified parameter in that it uses the parameter as its backing store.
All query operations get passed to the backing store, and all update operations
throw an UnsupportedOperationException
.
The returned Dates
object is serializable only if the parameter is serializable.
dates
- dates to treat as read-only
dates
java.lang.NullPointerException
- if dates
is null
public static <E,D> DatedValue<E,D> unmodifiableDatedValue(DatedValue<? extends E,D> datedValue)
In this implementation, the returned value "wraps"
the specified parameter in that it uses the parameter as its backing store.
All query operations get passed to the backing store, and all update operations
throw an UnsupportedOperationException
.
The returned dated value is serializable only if the parameter is serializable.
datedValue
- dated value to treat as read-only
java.lang.NullPointerException
- if the specified dated value is null
public static <E,D> DatedCollection<E,D> unmodifiableDatedCollection(DatedCollection<? extends E,D> datedCollection)
In this implementation, the returned collection "wraps"
the specified parameter in that it uses the parameter as its backing store.
All query operations get passed to the backing store, and all update operations
throw an UnsupportedOperationException
.
The returned dated collection is serializable only if the parameter is serializable.
datedCollection
- dated collection to treat as read-only
java.lang.NullPointerException
- if the specified dated collection is null
public static <E,D> DatedSet<E,D> unmodifiableDatedSet(DatedSet<? extends E,D> datedSet)
In this implementation, the returned set "wraps"
the specified parameter in that it uses the parameter as its backing store.
All query operations get passed to the backing store, and all update operations
throw an UnsupportedOperationException
.
The returned dated set is serializable only if the parameter is serializable.
datedSet
- dated set to treat as read-only
java.lang.NullPointerException
- if the specified dated set is null
public static <E,D> DatedList<E,D> unmodifiableDatedList(DatedList<? extends E,D> datedList)
In this implementation, the returned list "wraps"
the specified parameter in that it uses the parameter as its backing store.
All query operations get passed to the backing store, and all update operations
throw an UnsupportedOperationException
.
The returned dated list is serializable only if the parameter is serializable.
Also, the returned dated list implements RandomAccess
if the parameter implements
RandomAccess
.
datedList
- dated list to treat as read-only
java.lang.NullPointerException
- if the specified dated list is null
public static <K,V,D> DatedMap<K,V,D> unmodifiableDatedMap(DatedMap<? extends K,? extends V,D> datedMap)
In this implementation, the returned map "wraps"
the specified parameter in that it uses the parameter as its backing store.
All query operations get passed to the backing store, and all update operations
throw an UnsupportedOperationException
.
The returned dated map is serializable only if the parameter is serializable.
datedMap
- dated map to treat as read-only
java.lang.NullPointerException
- if the specified dated map is null
public static <K,V,D> DatedSortedMap<K,V,D> unmodifiableDatedSortedMap(DatedSortedMap<K,? extends V,D> datedSortedMap)
In this implementation, the returned sorted map "wraps"
the specified parameter in that it uses the parameter as its backing store.
All query operations get passed to the backing store, and all update operations
throw an UnsupportedOperationException
.
The returned dated sorted map is serializable only if the parameter is serializable.
datedSortedMap
- dated sorted map to treat as read-only
java.lang.NullPointerException
- if the specified dated sorted map is null
public static <E,D> DatedSortedSet<E,D> unmodifiableDatedSortedSet(DatedSortedSet<E,D> datedSortedSet)
In this implementation, the returned sorted set "wraps"
the specified parameter in that it uses the parameter as its backing store.
All query operations get passed to the backing store, and all update operations
throw an UnsupportedOperationException
.
The returned dated sorted set is serializable only if the parameter is serializable.
datedSortedSet
- dated sorted set to treat as read-only
java.lang.NullPointerException
- if the specified dated sorted set is null
public static <D> Dates<D> synchronizedDates(Dates<D> dates)
Dates
object synchronizes on itself at each
method invocation and then passes the operation on to the parameter.
Note that this implementation is coarse grained in that it does not allow
concurrent access to disjoint date ranges of the object.
The client must manually synchronize on the returned Dates
object
in order to iterate over the ranges safely, as follows:
Dates dates = ... Dateds syncDates = DatedCollections.synchronizedDates( dates ); synchronized( syncDates ) { DateIterator dateIter = syncDates.dateIterator(); while( dateIter.hasNext() ) { ... } }The returned dated object is serializable only if the parameter is serializable.
dates
- series of date ranges to be thread-safe
dates
that multiple threads may safely access
java.lang.NullPointerException
- if the specified dated object is null
public static <D> DatedObject<D> synchronizedDatedObject(DatedObject<D> datedObject)
The client must manually synchronize on the returned dated object in order to iterate over the dates safely, as follows:
DateObject obj = ... DatedObject syncObj = DatedCollections.synchronizedDatedObject( obj ); synchronized( syncObj ) { DateIterator dateIter = syncObj.dateIterator(); while( dateIter.hasNext() ) { ... } }To satisfy the contracts of
equals(Date,DatedObject,Date)
and hashCode(int)
in subtypes that
strengthen these contracts, the returned dated object does not forward
these calls to the parameter.The returned dated object is serializable only if the parameter is serializable.
datedObject
- dated object to be thread-safe
java.lang.NullPointerException
- if the specified dated ibject is null
public static <E,D> DatedValue<E,D> synchronizedDatedValue(DatedValue<E,D> datedValue)
The returned dated value is serializable only if the parameter is serializable.
datedValue
- dated value to be thread-safe
java.lang.NullPointerException
- if the specified dated value is null
synchronizedDatedObject(DatedObject)
public static <E,D> DatedCollection<E,D> synchronizedDatedCollection(DatedCollection<E,D> datedCollection)
Date someDate = ... DatedCollection coll = ... DatedCollection syncColl = DatedCollections.synchronizedDatedCollection( coll ); synchronized( syncColl ) { Iterator iter = syncColl.iterator( someDate ); while( iter.hasNext() ) { Object element = iter.next(); ... } }The returned dated collection is serializable only if the parameter is serializable.
datedCollection
- dated collection to be thread-safe
java.lang.NullPointerException
- if the specified dated collection is null
synchronizedDatedObject(DatedObject)
public static <E,D> DatedSet<E,D> synchronizedDatedSet(DatedSet<E,D> datedSet)
The returned dated set is serializable only if the parameter is serializable.
datedSet
- dated set to be thread-safe
java.lang.NullPointerException
- if the specified dated set is null
synchronizedDatedCollection(DatedCollection)
public static <E,D> DatedList<E,D> synchronizedDatedList(DatedList<E,D> datedList)
The returned dated set is serializable only if the parameter is serializable.
Also, the returned dated list implements RandomAccess
if the parameter
implements RandomAccess
.
datedList
- dated list to be thread-safe
java.lang.NullPointerException
- if the specified dated list is null
synchronizedDatedCollection(DatedCollection)
public static <K,V,D> DatedMap<K,V,D> synchronizedDatedMap(DatedMap<K,V,D> datedMap)
Date someDate = ... DatedMap map = ... DatedMap syncMap = DatedCollections.synchronizedDatedMap( map ); DatedSet entrySet = syncMap.entrySet(); synchronized( syncMap ) { Iterator iter = entrySet.iterator( someDate ); while( iter.hasNext() ) { DatedMap.Entry entry = (DatedMap.Entry)iter.next(); ... } }The returned dated map is serializable only if the parameter is serializable.
datedMap
- dated map to be thread-safe
java.lang.NullPointerException
- if the specified dated map is null
synchronizedDatedObject(DatedObject)
public static <K,V,D> DatedSortedMap<K,V,D> synchronizedDatedSortedMap(DatedSortedMap<K,V,D> datedSortedMap)
Date someDate = ... DatedMap map = ... DatedMap syncMap = DatedCollections.synchronizedDatedMap( map ); DatedMap headMap = syncMap.headMap( someKey ); DatedSet entrySet = headMap.entrySet(); synchronized( syncMap ) { Iterator iter = entrySet.iterator( someDate ); while( iter.hasNext() ) { DatedMap.Entry entry = (DatedMap.Entry)iter.next(); ... } }The returned dated sorted map is serializable only if the parameter is serializable.
datedSortedMap
- dated sorted map to be thread-safe
java.lang.NullPointerException
- if the specified dated sorted map is null
synchronizedDatedMap(DatedMap)
public static <E,D> DatedSortedSet<E,D> synchronizedDatedSortedSet(DatedSortedSet<E,D> datedSortedSet)
Date someDate = ... DatedSet set = ... DatedSet syncSet = DatedCollections.synchronizedDatedSet( set ); DatedMap tailSet = syncSet.tailSet( someElement ); synchronized( syncSet ) { Iterator iter = tailSet.iterator( someDate ); while( iter.hasNext() ) { Object element = iter.next(); ... } }The returned dated sorted set is serializable only if the parameter is serializable.
datedSortedSet
- dated sorted set to be thread-safe
java.lang.NullPointerException
- if the specified dated sorted set is null
synchronizedDatedCollection(DatedCollection)
public static <E,D> DatedValue<E,D> checkedDatedValue(DatedValue<E,D> datedValue, java.lang.Class<E> type)
The returned object is serializable only if the parameter is serializable.
datedValue
- dated value to wraptype
- the type of values that the dated value is allowed to hold
ClassCastException
when there
is an attempt to set the dated value with an object that is not assignable
to the class represented by type
public static <E,D> DatedCollection<E,D> checkedDatedCollection(DatedCollection<E,D> datedCollection, java.lang.Class<E> type)
The returned object is serializable only if the parameter is serializable.
datedCollection
- dated collection to wraptype
- the type of elements that the dated collection is allowed to hold
ClassCastException
when there
is an attempt to add an object that is not assignable
to the class represented by type
public static <E,D> DatedSet<E,D> checkedDatedSet(DatedSet<E,D> datedSet, java.lang.Class<E> type)
The returned object is serializable only if the parameter is serializable.
datedSet
- dated set to wraptype
- the type of elements that the dated set is allowed to hold
ClassCastException
when there
is an attempt to add an object that is not assignable
to the class represented by type
public static <E,D> DatedList<E,D> checkedDatedList(DatedList<E,D> datedList, java.lang.Class<E> type)
The returned object is serializable only if the parameter is serializable.
datedList
- dated list to wraptype
- the type of elements that the dated list is allowed to hold
ClassCastException
when there
is an attempt to add an object that is not assignable
to the class represented by type
public static <K,V,D> DatedMap<K,V,D> checkedDatedMap(DatedMap<K,V,D> datedMap, java.lang.Class<K> keyType, java.lang.Class<V> valueType)
The returned object is serializable only if the parameter is serializable.
datedMap
- dated map to wrapkeyType
- the type of keys that the dated map is allowed to holdvalueType
- the type of values that the dated map is allowed to hold
ClassCastException
when there
is an attempt to add a key that is not assignable to keyType
or a value that is not assignable to valueType
public static <K,V,D> DatedSortedMap<K,V,D> checkedDatedSortedMap(DatedSortedMap<K,V,D> datedSortedMap, java.lang.Class<K> keyType, java.lang.Class<V> valueType)
The returned object is serializable only if the parameter is serializable.
datedSortedMap
- dated sorted map to wrapkeyType
- the type of keys that the dated map is allowed to holdvalueType
- the type of values that the dated map is allowed to hold
ClassCastException
when there
is an attempt to add a key that is not assignable to keyType
or a value that is not assignable to valueType
public static <E,D> DatedSortedSet<E,D> checkedDatedSortedSet(DatedSortedSet<E,D> datedSortedSet, java.lang.Class<E> type)
The returned object is serializable only if the parameter is serializable.
datedSortedSet
- dated sorted set to wraptype
- the type of elements that the dated sorted set is allowed to hold
ClassCastException
when there
is an attempt to add an object that is not assignable
to the class represented by type
public static <E,D> void sort(DatedList<E,D> datedList, D from, D to)
datedList
- dated list to be sortedfrom
- start date of range (inclusive) to sort the listto
- end date of range (exclusive) to sort the list
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if any argument is nullpublic static <E,D> void sort(DatedList<E,D> datedList, java.util.Comparator<? super E> comparator, D from, D to)
datedList
- dated list to be sortedcomparator
- comparator used to determine ascending order (may be null)from
- start date of range (inclusive) to sort the listto
- end date of range (exclusive) to sort the list
java.lang.NullPointerException
- if datedList, from, or to is null
java.lang.IllegalArgumentException
- if from
does not precede to
public static <E,D> void shuffle(DatedList<E,D> datedList, D from, D to)
datedList
- dated list to be shuffledfrom
- start date of range (inclusive) to shuffle the listto
- end date of range (exclusive) to shuffle the list
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if any argument is nullpublic static <E,D> void shuffle(DatedList<E,D> datedList, java.util.Random rnd, D from, D to)
datedList
- dated list to be sortedrnd
- random number generator used to determine the permutationfrom
- start date of range (inclusive) to sort the listto
- end date of range (exclusive) to sort the list
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if datedList, from, or to is nullpublic static <E,D> void rotate(DatedList<E,D> datedList, int distance, D from, D to)
datedList
- dated list to be rotateddistance
- number of indices to shift the elements of the listfrom
- start date of range (inclusive) to rotate the listto
- end date of range (exclusive) to rotate the list
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if datedList, from, or to is nullpublic static <E,D> void reverse(DatedList<E,D> datedList, D from, D to)
datedList
- dated list to be reversedfrom
- start date of range (inclusive) to reverse the listto
- end date of range (exclusive) to reverse the list
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if any argument is nullpublic static <E,D> Dates<D> addAll(DatedCollection<? super E,D> datedCollection, D from, D to, E... elements)
datedCollection
- dated collection for which to add the elementsfrom
- start date (inclusive) for which to add the elementsto
- end date (exclusive) for which to add the elementselements
- the objects to add
java.lang.ClassCastException
- if the type of an element prevents it from
being added to the dated collection
java.lang.IllegalArgumentException
- if some property of an element prevents it from
being added to the dated collection
java.lang.NullPointerException
- if datedCollection
is null
or if an element is null
and the dated collection cannot hold null elements
java.lang.UnsupportedOperationException
- if the dated collection does not support addAll
public static <D> boolean disjoint(DatedCollection<?,D> datedCollection1, DatedCollection<?,D> datedCollection2, D at)
datedCollection1
- first collectiondatedCollection2
- second collectionat
- date at which to check if the dated collections are disjoint
true
if the two dated collections are disjoing at the specified date
java.lang.NullPointerException
- if any argument is null
public static <D> int frequency(DatedCollection<?,D> datedCollection, java.lang.Object object, D at)
datedCollection
- dated collection to be searchedobject
- element to countat
- date at which to retrieve the frequency
object
in datedCollection
at date at
java.lang.NullPointerException
- if datedCollection
or at
is null
public static <E,D> E max(DatedCollection<E,D> datedCollection, D at)
datedCollection
- dated collection to be searchedat
- date to search the collection
java.util.NoSuchElementException
- if the dated collection is empty at the specified date
java.lang.NullPointerException
- if any argument is nullmax(DatedCollection,Comparator,Object)
,
min(DatedCollection,Object)
public static <E,D> E max(DatedCollection<E,D> datedCollection, java.util.Comparator<? super E> comparator, D at)
datedCollection
- dated collection to be searchedcomparator
- comparator used to order the elements (may be null)at
- date to search the collection
java.util.NoSuchElementException
- if the dated collection is empty at the specified date
java.lang.NullPointerException
- if datedCollection or date is nullmax(DatedCollection,Object)
,
min(DatedCollection,Comparator,Object)
public static <E,D> E min(DatedCollection<E,D> datedCollection, D at)
datedCollection
- dated collection to be searchedat
- date to search the collection
java.util.NoSuchElementException
- if the dated collection is empty at the specified date
java.lang.NullPointerException
- if any argument is nullmin(DatedCollection,Comparator,Object)
,
max(DatedCollection,Object)
public static <E,D> E min(DatedCollection<E,D> datedCollection, java.util.Comparator<? super E> comparator, D at)
datedCollection
- dated collection to be searchedcomparator
- comparator used to order the elements (may be null)at
- date to search the collection
java.util.NoSuchElementException
- if the dated collection is empty at the specified date
java.lang.NullPointerException
- if datedCollection or date is nullmin(DatedCollection,Object)
,
max(DatedCollection,Comparator,Object)
public static <E,D> int binarySearch(DatedList<? extends java.lang.Comparable<? super E>,D> datedList, E key, D at)
datedList
- dated list to be searchedkey
- element to look for in the listat
- date to search the list
java.lang.NullPointerException
- if datedList or date is nullpublic static <E,D> int binarySearch(DatedList<? extends E,D> datedList, E key, java.util.Comparator<? super E> comparator, D at)
datedList
- dated list to be searchedkey
- element to look for in the listcomparator
- comparator used to order the elements of the list (may be null)at
- date to search the list
java.lang.NullPointerException
- if datedList or date is nullpublic static <D> void swap(DatedList<?,D> datedList, int i, int j, D from, D to)
datedList
- dated list holding the elements to be swappedi
- index of an element to be swappedj
- index of the other element to be swappedfrom
- start date of range (inclusive) to perform the swapto
- end date of range (exclusive) to perform the swap
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.IndexOutOfBoundsException
- if i > size(d) or j > size(d) for any d
between from and to
java.lang.NullPointerException
- if datedList, from, or to is nullpublic static <E,D> Dates<D> replaceAll(DatedList<E,D> datedList, E oldVal, E newVal, D from, D to)
datedList
- dated list holding the elements to replaceoldVal
- element to replacenewVal
- element to substitute for oldValfrom
- start date of range (inclusive) to perform the substitutionto
- end date of range (exclusive) to perform the substitution
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if datedList, from, or to is null
java.lang.UnsupportedOperationException
- if the dated list does not support the setting
of elementspublic static <E,D> void fill(DatedList<? super E,D> datedList, E obj, D from, D to)
datedList
- dated list to fillobj
- element to put in listfrom
- start date of range (inclusive) to fill the listto
- end date of range (exclusive) to fill the list
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if datedList, from, or to is null
java.lang.UnsupportedOperationException
- if the dated list does not support the setting
of elementspublic static <D> int indexOfSubList(DatedList<?,D> datedList, java.util.List<?> target, D at)
datedList
- dated list to searchtarget
- list elements to search forat
- date to check for occurrence in the dated list
java.lang.NullPointerException
- if any argument is nullpublic static <D> int lastIndexOfSubList(DatedList<?,D> datedList, java.util.List<?> target, D at)
datedList
- dated list to searchtarget
- list elements to search forat
- date to check for occurrence in the dated list
java.lang.NullPointerException
- if any argument is nullpublic static <E,D> void copy(DatedList<? super E,D> datedList, java.util.List<? extends E> src, D from, D to)
datedList
- dated list to copy intosrc
- list of elements to copyfrom
- start date of range (inclusive) to copy intoto
- end date of range (exclusive) to copy into
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.IndexOutOfBoundsException
- if the destination dated list does not have enough
cells to hold the elements of src at some time within the range
java.lang.NullPointerException
- if any argument is null
java.lang.UnsupportedOperationException
- if the destination dated list does not support the setting
of elementspublic static <E,D> DatedSet<E,D> singletonDatedSet(E o, D from, D to)
o
- object to include in the returned setfrom
- start date of range (inclusive) for the returned dated set
to contain the objectto
- end date of range (exclusive) for the returned dated set
to contain the object
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if from or to is nullpublic static <E,D> DatedList<E,D> singletonDatedList(E o, D from, D to)
o
- object to include in the returned listfrom
- start date of range (inclusive) for the returned dated list
to contain the objectto
- end date of range (exclusive) for the returned dated list
to contain the object
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if from or to is nullpublic static <K,V,D> DatedMap<K,V,D> singletonDatedMap(K key, V value, D from, D to)
key
- key to include in the returned mapvalue
- value to be associated with key in the returned mapfrom
- start date of range (inclusive) for the returned dated map
to contain the objectto
- end date of range (exclusive) for the returned dated map
to contain the object
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if from or to is nullpublic static <E,D> DatedList<E,D> nCopies(int n, E o, D from, D to)
n
- number of copies of o to include in the returned listo
- object to include in the returned listfrom
- start date of range (inclusive) for the returned dated list
to contain n copies of the objectto
- end date of range (exclusive) for the returned dated list
to contain n copies of the object
java.lang.IllegalArgumentException
- if from
does not precede to
or if n < 0
java.lang.NullPointerException
- if from or to is null
|
Side of Software Dated Collections Library 2.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |