T - The type of objects associated with each timepoint/timestamp.public class History<T> extends Object implements Serializable
This is a generic implementation of a history. Basically a history associates
items of type T with timestamps, which are grouped to discrete
timestamps, e.g. every full hour, every 5 minutes, etc.
The type T is usually a data structure, which allows aggregation
of multiple values of nearby time points.
| Modifier and Type | Field and Description |
|---|---|
static long |
DAY |
(package private) long |
historyLength |
static long |
HOUR |
(package private) long |
last |
(package private) LinkedHashMap<Long,T> |
map |
static long |
MILLISECOND |
static long |
MINUTE |
static long |
MONTH |
static long |
SECOND |
private static long |
serialVersionUID
The unique class ID
|
(package private) long |
stepSize |
static long |
WEEK |
static long |
YEAR |
| Constructor and Description |
|---|
History(long stepSize,
long historyLength) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Long timestamp,
T data) |
protected Long |
adjust(Long timestamp)
This method maps the given timestamp to the last official
timestamp, as induced by the stepSize.
|
void |
clear() |
void |
forget()
This method removes any data that is associated with a timestamp older
than
historyLength milliseconds. |
T |
get(int i) |
T |
get(Long timestamp) |
List<T> |
getData() |
Long |
getLength() |
int |
getPosition(Long timestamp) |
int |
getSteps() |
long |
getStepSize()
Returns the step size for this history.
|
Long |
getTimestamp(int i) |
protected long |
last()
Returns the last official timestamp for this history.
|
Long |
map(int i)
Returns the timestamp for the ith element of this history.
|
Long |
mapTimestamp(Long timestamp) |
private static final long serialVersionUID
public static final long MILLISECOND
public static final long SECOND
public static final long MINUTE
public static final long HOUR
public static final long DAY
public static final long WEEK
public static final long MONTH
public static final long YEAR
long stepSize
long historyLength
LinkedHashMap<Long,T> map
long last
public long getStepSize()
public Long getLength()
org.jwall.web.audit.console.statistics.History#getLength()public T get(int i)
org.jwall.web.audit.console.statistics.History#get(int)public int getPosition(Long timestamp)
org.jwall.web.audit.console.statistics.History#getPosition(java.lang.Long)public int getSteps()
org.jwall.web.audit.console.statistics.History#getSteps()public Long getTimestamp(int i)
org.jwall.web.audit.console.statistics.History#getTimestamp(int)public T get(Long timestamp)
org.jwall.web.audit.console.statistics.History#get(java.lang.Long)public void add(Long timestamp, T data)
org.jwall.web.audit.console.statistics.History#add(java.lang.Long,
java.lang.Object)protected Long adjust(Long timestamp)
timestamp - public void forget()
historyLength milliseconds. Items will only be removed
if older than historyLength AND there are more than
getSteps() items contained in this history.protected long last()
public Long map(int i)
i - public void clear()
Copyright © 2018. All rights reserved.