Skip to content

Commit

Permalink
Clarifications for ActionFrequency.
Browse files Browse the repository at this point in the history
  • Loading branch information
asofold committed Feb 9, 2015
1 parent 85dcb33 commit 75cc31e
Showing 1 changed file with 16 additions and 6 deletions.
Expand Up @@ -8,8 +8,12 @@
*/
public class ActionFrequency {

/** Reference time for filling in. */
/** Reference time for the transition from the first to the second bucket. */
private long time = 0;
/**
* Time of last update (add). Should be the "time of the last event" for the
* usual case.
*/
private long lastUpdate = 0;
private final boolean noAutoReset;

Expand Down Expand Up @@ -45,7 +49,7 @@ public ActionFrequency(final int nBuckets, final long durBucket, final boolean n
}

/**
* Update and add.
* Update and add (updates reference and update time).
* @param now
* @param amount
*/
Expand All @@ -63,7 +67,9 @@ public final void add(final float amount) {
}

/**
* Update without adding, also updates time. Detects time running backwards.
* Update without adding, also updates reference and update time. Detects
* time running backwards.
*
* @param now
*/
public final void update(final long now) {
Expand Down Expand Up @@ -99,6 +105,10 @@ else if (diff < durBucket) {
lastUpdate = now;
}

/**
* Clear all counts, reset reference and update time.
* @param now
*/
public final void clear(final long now) {
for (int i = 0; i < buckets.length; i++) {
buckets[i] = 0f;
Expand Down Expand Up @@ -189,7 +199,7 @@ public final void setBucket(final int n, final float value) {
}

/**
* Set the reference time.
* Set the reference time and last update time.
* @param time
*/
public final void setTime(final long time) {
Expand All @@ -198,15 +208,15 @@ public final void setTime(final long time) {
}

/**
* Get reference time.
* Get the reference time for the transition from the first to the second bucket.
* @return
*/
public final long lastAccess() { // TODO: Should rename this.
return time;
}

/**
*
* Get the last time when update was called (adding).
* @return
*/
public final long lastUpdate() {
Expand Down

0 comments on commit 75cc31e

Please sign in to comment.