Removing the next state allows a LRU buffer of states -- but states can't simple be discarded, they have to be more carefully managed because most states only track deltas. Things like memory have to be merged correctly. This state will merge with the next state and then remove it from the linked l
()
| 52 | * @return |
| 53 | */ |
| 54 | public State deleteNext() { |
| 55 | if (nextState == null) { |
| 56 | return null; |
| 57 | } |
| 58 | if (nextState.deltaState) { |
| 59 | putAll(nextState); |
| 60 | |
| 61 | nextState = nextState.nextState; |
| 62 | |
| 63 | if (nextState == null) { |
| 64 | tail = this; |
| 65 | } |
| 66 | return this; |
| 67 | } else { |
| 68 | nextState.tail = tail; |
| 69 | nextState.previousState = previousState; |
| 70 | return nextState; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | public void addState(State newState) { |
| 75 | newState.previousState = this; |