Skip to content

Package: IGameMemory

IGameMemory

Coverage

1: package de.fhdw.gaming.ipspiel23.memory;
2:
3: /**
4: * Interface for a game memory that stores and retrieves round data.
5: *
6: * @param <ROUND_DATA> the type of round data to be stored.
7: */
8: public interface IGameMemory<ROUND_DATA> {
9:
10: /**
11: * number of rounds that are currently stored, must be >= 0 (duh).
12: */
13: int size();
14:
15: /**
16: * maximum possible number of rounds that can be stored.
17: * -1 means unlimited.
18: */
19: int capacity();
20:
21: /**
22: * adds a round, potentially overriding the oldest round data, if capacity() is reached.
23: *
24: * @param round the round data to add.
25: */
26: void add(ROUND_DATA round);
27:
28: /**
29: * resets this memory instance to its initial state.
30: */
31: void clear();
32:
33: /**
34: * returns the round at the specified index relative to the oldest round in the data set,
35: * such that index = 0, fromEnd = false will always return the oldest round (furthest in the past),
36: * while index = 0, fromEnd = true will return the latest round (the round that just happened).
37: * The index must always be 0 <= index < capacity()
38: *
39: * @param index the index of the round data to retrieve.
40: * @param fromEnd if true, retrieves the round data from the end of the buffer.
41: * @return the round data at the specified index, or null if the buffer is empty.
42: */
43: ROUND_DATA getRound(int index, boolean fromEnd);
44:
45: /**
46: * Returns the round data at the specified index.
47: * Counted from the end of the buffer.
48: *
49: * @param index the index of the round data to retrieve.
50: * @return the round data at the specified index, or null if the buffer is
51: * empty.
52: */
53: ROUND_DATA getRound(int index);
54:
55: /**
56: * Returns the latest round data in the buffer.
57: *
58: * @return the latest round data in the buffer, or null if the buffer is empty.
59: */
60: ROUND_DATA getLatestRound();
61: }