* Make the history table forget its first N elements, shifting its indexes in the process. * `N` being given as the `numberOfEntriesToForget` parameter. * * @param {Number} [numberOfEntriesToForget=1] (Optional, default: 1) * @returns {HistoryTableEntry|Array }
(numberOfEntriesToForget = 1)
| 1799 | * @private |
| 1800 | */ |
| 1801 | _historyTableForget(numberOfEntriesToForget = 1) { |
| 1802 | const shiftedAway = []; |
| 1803 | for (let i = 0; i < numberOfEntriesToForget; i++) { |
| 1804 | shiftedAway.push(this.historyTable.shift()); |
| 1805 | // Update the history table index accordingly |
| 1806 | this.historyTableIndex--; |
| 1807 | if (this.historyTableIndex < 0) { |
| 1808 | // In case this function is called more times than there is states in the history table |
| 1809 | this.historyTableIndex = 0; |
| 1810 | } |
| 1811 | } |
| 1812 | |
| 1813 | if (shiftedAway.length === 1) { |
| 1814 | return shiftedAway[0]; |
| 1815 | } |
| 1816 | |
| 1817 | return shiftedAway; |
| 1818 | } |
| 1819 | |
| 1820 | /** |
| 1821 | * Return the currently used value from the history table. |