T
- the value typepublic class RegularTimeSeries<T> extends AbstractTimeSeries<T> implements TimeIndexable<T>
TimeIndexable
.
This implementation provides no synchronization.
The maximum allowed gap in a time series is by default 500. It can be set to another value using the system property "RegularTimeSeries.MaxGap".
Modifier and Type | Class and Description |
---|---|
class |
RegularTimeSeries.TimeSeriesIterator
TimeSeriesIterator is an
Iterator returning Observation objects. |
Modifier and Type | Field and Description |
---|---|
static String |
MAXGAP_PROPERTY |
Constructor and Description |
---|
RegularTimeSeries(Class<T> type,
TimeDomain domain)
Construct a regular time series.
|
RegularTimeSeries(Class<T> type,
TimeDomain domain,
T missingValue)
Construct a regular time series.
|
Modifier and Type | Method and Description |
---|---|
TimeIndexable<T> |
asIndexable()
Return an indexable time series corresponding to this one.
|
TimeIndexable<T> |
copy()
Return a copy of the time series.
|
int |
fill(Filler<T> interpolator)
Fill holes using the given procedure.
|
int |
fill(long tailLength)
Fill holes in the time series by repeating the last value before each
hole and append a tail by repeating the last value a given number of
times.
|
int |
fill(T replacement,
long tailLength)
Fill holes in the time series with the given value and append a
tail of the given length.
|
TimeAddressable<T> |
get(long first,
long last)
Return a new time series corresponding to the range between two numerical time indexes.
|
TimeAddressable<T> |
get(Range range)
Return a time series constructed from the given range of this series.
|
T[] |
getArray()
Return all the values in an array.
|
T[] |
getArray(Range range)
Return a subrange of values in an array.
|
int |
getMaxGap()
Return the maximum allowed length of a single run of missing values.
|
int |
getValueCount()
Return the number of non-missing values.
|
protected void |
internalClear()
Remove all values from the time series.
|
protected T |
internalGet(long index)
Get the value identified by the given numerical time index.
|
protected Collection<T> |
internalGetData()
Return all values as a
Collection . |
protected Observation<T> |
internalGetFirst(long index)
Return the observation at or after the given numerical time index.
|
protected long |
internalGetFirstIndex()
Return the numerical time index of the first element.
|
protected Observation<T> |
internalGetLast(long index)
Return the observation at or before the given numerical time index.
|
protected long |
internalGetLastIndex()
Return the numerical time index of the last element.
|
protected int |
internalGetSize()
Return the used size of the data structure where values are stored.
|
protected void |
internalPut(long index,
T value)
Put the value into the series at the given numerical time index.
|
protected void |
internalRemove(long index)
Remove the value at the given numerical time index.
|
protected void |
internalSetBounds(long first,
long last)
Shrink the range to the one given by the two numerical time indexes.
|
boolean |
isIndexable()
Return true if the time series implements
TimeIndexable . |
Iterator<Observation<T>> |
iterator()
Returns an iterator over the
Observation s in the time series
ordered by increasing time index. |
TimeIndexable<T> |
makeEmptyCopy()
Make a copy of the time series but without the values.
|
void |
put(long index,
T[] values)
Put an array of values identified with the numerical time index of its
first element into the time series.
|
void |
put(TimeAddressable<T> values,
UpdateReviewer<T> reviewer)
Conditionally put all values from another time series into this time series.
|
accept, get, get, getFirst, getFirstIndex, getLast, getLastIndex, getMissingValue, getRange, getSize, getTimeDomain, getType, isMissing, make, normalizeMissingValue, put, put, put, remove, setRange, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
get, get, getFirst, getFirstIndex, getLast, getLastIndex, getMissingValue, getRange, getSize, getTimeDomain, getType, isMissing, put, put, put, remove, setRange
forEach, spliterator
public static final String MAXGAP_PROPERTY
public RegularTimeSeries(Class<T> type, TimeDomain domain, T missingValue)
type
- a non-null data typedomain
- a non-null time domainmissingValue
- an object representing missing valuespublic RegularTimeSeries(Class<T> type, TimeDomain domain)
Double.NaN
for type Double
and null for all other types.type
- a non-null data typedomain
- a non-null time domainpublic Iterator<Observation<T>> iterator()
TimeIndexable
Observation
s in the time series
ordered by increasing time index. In contrast to
TimeAddressable.iterator()
, this iterator returns all missing
valuesiterator
in interface TimeAddressable<T>
iterator
in interface TimeIndexable<T>
iterator
in interface Iterable<Observation<T>>
public TimeAddressable<T> get(Range range) throws T2Exception
TimeAddressable
get
in interface TimeAddressable<T>
range
- a non-null rangeT2Exception
public TimeAddressable<T> get(long first, long last) throws T2Exception
TimeAddressable
get
in interface TimeAddressable<T>
get
in class AbstractTimeSeries<T>
first
- a numerical time index giving the lower bound of the wanted rangelast
- a numerical time index giving the upper bound of the wanted rangeT2Exception
protected Observation<T> internalGetLast(long index) throws T2Exception
AbstractTimeSeries
Observation
, only a special rule for this method).internalGetLast
in class AbstractTimeSeries<T>
index
- a numerical time indexT2Exception
protected Observation<T> internalGetFirst(long index) throws T2Exception
AbstractTimeSeries
Observation
, only a special rule for this method).internalGetFirst
in class AbstractTimeSeries<T>
index
- a numberT2Exception
public int getValueCount()
TimeAddressable
getValueCount
in interface TimeAddressable<T>
public boolean isIndexable()
TimeAddressable
TimeIndexable
.isIndexable
in interface TimeAddressable<T>
public int getMaxGap()
TimeIndexable
getMaxGap
in interface TimeIndexable<T>
public TimeIndexable<T> makeEmptyCopy()
TimeAddressable
makeEmptyCopy
in interface TimeAddressable<T>
makeEmptyCopy
in interface TimeIndexable<T>
public TimeIndexable<T> asIndexable() throws T2Exception
TimeAddressable
asIndexable
in interface TimeAddressable<T>
T2Exception
public TimeIndexable<T> copy() throws T2Exception
TimeAddressable
copy
in interface TimeAddressable<T>
copy
in interface TimeIndexable<T>
copy
in class AbstractTimeSeries<T>
T2Exception
public T[] getArray()
TimeIndexable
getArray
in interface TimeIndexable<T>
public T[] getArray(Range range) throws T2Exception
TimeIndexable
getArray
in interface TimeIndexable<T>
range
- the non-null wanted rangeT2Exception
public void put(long index, T[] values) throws T2Exception
TimeAddressable
put
in interface TimeAddressable<T>
put
in class AbstractTimeSeries<T>
index
- a numerical time indexvalues
- a non-null array of valuesT2Exception
public void put(TimeAddressable<T> values, UpdateReviewer<T> reviewer) throws T2Exception
TimeAddressable
Important note. When the implementation of the values time series
does not explicitly represent missing values (see SparseTimeSeries
for example),
this method cannot be relied upon for "deleting" values of the target.
put
in interface TimeAddressable<T>
put
in class AbstractTimeSeries<T>
values
- a non-null time seriesreviewer
- a reviewerT2Exception
public int fill(T replacement, long tailLength) throws T2Exception
TimeIndexable
Note: the method can be used to count missing values by specify a missing value as replacement. In this case it is illegal to specify a positive tail length.
fill
in interface TimeIndexable<T>
replacement
- the replacement valuetailLength
- the length of the tail to appendT2Exception
public int fill(long tailLength)
TimeIndexable
fill
in interface TimeIndexable<T>
tailLength
- the number of times the last value must be repeatedpublic int fill(Filler<T> interpolator) throws T2Exception
TimeIndexable
fill
in interface TimeIndexable<T>
interpolator
- a non-null fillerT2Exception
protected void internalClear()
AbstractTimeSeries
internalClear
in class AbstractTimeSeries<T>
protected T internalGet(long index) throws T2Exception
AbstractTimeSeries
internalGet
in class AbstractTimeSeries<T>
index
- a numerical time indexT2Exception
protected Collection<T> internalGetData()
AbstractTimeSeries
Collection
.internalGetData
in class AbstractTimeSeries<T>
protected long internalGetFirstIndex()
AbstractTimeSeries
internalGetFirstIndex
in class AbstractTimeSeries<T>
protected long internalGetLastIndex()
AbstractTimeSeries
internalGetLastIndex
in class AbstractTimeSeries<T>
protected int internalGetSize()
AbstractTimeSeries
internalGetSize
in class AbstractTimeSeries<T>
protected void internalPut(long index, T value) throws T2Exception
AbstractTimeSeries
The method silently ignores missing values added out of range. Adding missing values at the boundary shrinks the range.
internalPut
in class AbstractTimeSeries<T>
index
- a numerical time indexvalue
- a valueT2Exception
protected void internalRemove(long index) throws T2Exception
AbstractTimeSeries
internalRemove
in class AbstractTimeSeries<T>
index
- a numerical time indexT2Exception
protected void internalSetBounds(long first, long last) throws T2Exception
AbstractTimeSeries
internalSetBounds
in class AbstractTimeSeries<T>
first
- a numerical time index giving the lower bound of the new rangelast
- a numerical time index giving the upper bound of the new rangeT2Exception
Copyright © 2017. All rights reserved.