1 package cz.cuni.amis.utils.statistic;
2
3 /**
4 * Represents interface to the moving average value.
5 *
6 * @author Jimmy
7 *
8 * @param <TYPE>
9 */
10 public interface IMovingAverage<TYPE> {
11
12 /**
13 * Add another item into the moving average.
14 * @param item
15 */
16 public void add(TYPE item);
17
18 /**
19 * Returns an average of all items stored.
20 * <p><p>
21 * Returns null if no values are stored.
22 * @return
23 */
24 public TYPE getAverage();
25
26 /**
27 * Return current number of items that are used to compute the average returned
28 * via {@link IMovingAverage#getAverage()}.
29 * @return
30 */
31 public int getCurrentLength();
32
33 /**
34 * Return max number of consecutive items (added via {@link IMovingAverage#add(Object)} that are used to
35 * compute the average returned via {@link IMovingAverage#getAverage()}.
36 * @return
37 */
38 public int getMaxLength();
39
40 /**
41 * Sets number of items that the object requires for the computing of the average.
42 * (Note that computation is done all the time, but when there is enough items == set number,
43 * the {@link IMovingAverage#isEnoughValues()} reports true.)
44 *
45 * @param length
46 */
47 public void setMaxLength(int length);
48
49 /**
50 * Whether the object has enough values to compute the avarage according to the max numbers it
51 * may store (returns {@link IMovingAverage#getCurrentLength()} == {@link IMovingAverage#getMaxLength()}.
52 *
53 * @returns whether you may use {@link IMovingAverage#getAverage()} with the result that is desirable (i.e., the object has enough
54 * items to compute the average from)
55 */
56 public boolean isEnoughValues();
57
58 /**
59 * Resets the object -> it removes all items stored. The {@link IMovingAverage#getAverage()} will return
60 * null after the call.
61 */
62 public void reset();
63
64
65 }