T
- the type of dataKK
- the type the field elementpublic class ImmutableFieldTimeStampedCache<T extends FieldTimeStamped<KK>,KK extends org.hipparchus.CalculusFieldElement<KK>> extends Object implements FieldTimeStampedCache<T,KK>
TimeStamped
data that provides concurrency through immutability. This strategy is suitable when all the
cached data is stored in memory. (For example, UTCScale
) This class then provides
convenient methods for accessing the data.Constructor and Description |
---|
ImmutableFieldTimeStampedCache(int neighborsSize,
Collection<? extends T> data)
Create a new cache with the given neighbors size and data.
|
Modifier and Type | Method and Description |
---|---|
static <TS extends FieldTimeStamped<CFE>,CFE extends org.hipparchus.CalculusFieldElement<CFE>> |
emptyCache(org.hipparchus.Field<CFE> field)
Get an empty immutable cache, cast to the correct type.
|
List<T> |
getAll()
Get all the data in this cache.
|
T |
getEarliest()
Get the earliest entry in this cache.
|
T |
getLatest()
Get the latest entry in this cache.
|
Stream<T> |
getNeighbors(FieldAbsoluteDate<KK> central)
Get the entries surrounding a central date.
|
int |
getNeighborsSize()
Get the fixed size of the lists returned by
FieldTimeStampedCache.getNeighbors(FieldAbsoluteDate) . |
String |
toString() |
public ImmutableFieldTimeStampedCache(int neighborsSize, Collection<? extends T> data)
neighborsSize
- the size of the list returned from getNeighbors(FieldAbsoluteDate)
. Must be less than or
equal to data.size()
.data
- the backing data for this cache. The list will be copied to ensure immutability. To guarantee immutability
the entries in data
must be immutable themselves. There must be more data than neighborsSize
.IllegalArgumentException
- if neighborsSize > data.size()
or if neighborsSize
is negativepublic static <TS extends FieldTimeStamped<CFE>,CFE extends org.hipparchus.CalculusFieldElement<CFE>> ImmutableFieldTimeStampedCache<TS,CFE> emptyCache(org.hipparchus.Field<CFE> field)
TS
- the type of dataCFE
- the type of the calculus field elementfield
- field to which the elements belongImmutableTimeStampedCache
.public Stream<T> getNeighbors(FieldAbsoluteDate<KK> central)
If the central date is well within covered range, the returned array will be balanced with half the points before central date and half the points after it (depending on n parity, of course). If the central date is near the boundary, then the returned array will be unbalanced and will contain only the n earliest (or latest) entries. A typical example of the later case is leap seconds cache, since the number of leap seconds cannot be arbitrarily increased.
This method is safe for multiple threads to execute concurrently.
getNeighbors
in interface FieldTimeStampedCache<T extends FieldTimeStamped<KK>,KK extends org.hipparchus.CalculusFieldElement<KK>>
central
- central dateFieldTimeStampedCache.getNeighborsSize()
.public int getNeighborsSize()
FieldTimeStampedCache.getNeighbors(FieldAbsoluteDate)
.getNeighborsSize
in interface FieldTimeStampedCache<T extends FieldTimeStamped<KK>,KK extends org.hipparchus.CalculusFieldElement<KK>>
public T getEarliest()
getEarliest
in interface FieldTimeStampedCache<T extends FieldTimeStamped<KK>,KK extends org.hipparchus.CalculusFieldElement<KK>>
public T getLatest()
getLatest
in interface FieldTimeStampedCache<T extends FieldTimeStamped<KK>,KK extends org.hipparchus.CalculusFieldElement<KK>>
public List<T> getAll()
constructor
.Copyright © 2002-2023 CS GROUP. All rights reserved.