T
- public class SparseTimeSeries<T> extends AbstractTimeSeries<T> implements TimeAddressable<T>
TimeAddressable
. Missing values are never
stored in a sparse time series, but nulls can be stored, unless they are used
for representing missing values.
This implementation provides no synchronization.
Modifier and Type | Class and Description |
---|---|
class |
SparseTimeSeries.IrregularTimeSeriesIterator
IrregularTimeSeriesIterator is an
Iterator returning
Observation objects. |
Constructor and Description |
---|
SparseTimeSeries(Class<T> type,
TimeDomain domain)
Construct a sparse time series with the given type and time domain.
|
SparseTimeSeries(Class<T> type,
TimeDomain domain,
T missingValue)
Construct a sparse time series with the given type, time domain and missing
value.
|
Modifier and Type | Method and Description |
---|---|
TimeIndexable<T> |
asIndexable()
Return an indexable time series corresponding to this one.
|
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.
|
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. |
TimeAddressable<T> |
makeEmptyCopy()
Make a copy of the time series but without the values.
|
accept, copy, get, get, getFirst, getFirstIndex, getLast, getLastIndex, getMissingValue, getRange, getSize, getTimeDomain, getType, isMissing, make, normalizeMissingValue, put, put, put, put, put, remove, setRange, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
copy, get, get, getFirst, getFirstIndex, getLast, getLastIndex, getMissingValue, getRange, getSize, getTimeDomain, getType, isMissing, put, put, put, put, put, remove, setRange
forEach, spliterator
public SparseTimeSeries(Class<T> type, TimeDomain domain, T missingValue)
type
- a non-null data typedomain
- a non-null time domainmissingValue
- an object representing missing valuespublic SparseTimeSeries(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()
TimeAddressable
Observation
s in the time series
ordered by increasing time index. This iterator does not return any
missing value.iterator
in interface TimeAddressable<T>
iterator
in interface Iterable<Observation<T>>
public TimeAddressable<T> makeEmptyCopy()
TimeAddressable
makeEmptyCopy
in interface TimeAddressable<T>
public TimeIndexable<T> asIndexable() throws T2Exception
TimeAddressable
asIndexable
in interface TimeAddressable<T>
T2Exception
public TimeAddressable<T> get(long first, long last)
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 rangepublic TimeAddressable<T> get(Range range) throws T2Exception
TimeAddressable
get
in interface TimeAddressable<T>
range
- a non-null 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>
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.