This commit is contained in:
thrust26 2017-12-09 10:41:55 +01:00
commit 9ae7ab0ed4
3 changed files with 16 additions and 18 deletions

View File

@ -97,17 +97,15 @@ class LinkedObjectPool
myCurrent = std::next(myCurrent, 1);
}
#if 0
/**
Return a reference to the element at the first node in the active list.
Return an iterator to the first node in the active list.
*/
T& first() { return myList.front(); }
iter first() { return myList.begin(); }
/**
Return a reference to the element at the last node in the active list.
Return an iterator to the last node in the active list.
*/
T& last() { return myList.back(); }
#endif
iter last() { return std::prev(myList.end(), 1); }
/**
Add a new node at the beginning of the active list, and update 'current'
@ -193,12 +191,13 @@ class LinkedObjectPool
myCurrent = myList.end();
}
#if 0
/** Access the list with iterators, just as you would a normal C++ STL list */
iter begin() { return myList.begin(); }
iter end() { return myList.end(); }
const_iter begin() const { return myList.cbegin(); }
const_iter end() const { return myList.cend(); }
#endif
uInt32 capacity() const { return CAPACITY; }
uInt32 size() const { return myList.size(); }

View File

@ -128,16 +128,10 @@ void RewindManager::compressStates()
double maxDelta = 0;
uInt32 removeIdx = 0;
uInt32 idx = 0;
for(auto it = myStateList.begin(); it != myStateList.end(); ++it)
uInt32 idx = myStateList.size() - 1;
for(auto it = myStateList.last(); it != myStateList.first(); --it)
{
// test and never remove the very first saved state
if(++it == myStateList.end())
{
break;
}
--it; // UGLY!
cerr << *it << endl << endl; // debug code
if(idx >= STEP_STATES)
{
expectedCycles *= DENSITY;
@ -154,7 +148,7 @@ void RewindManager::compressStates()
}
}
lastCycle = it->cycle;
idx++;
--idx;
}
if (maxDelta < 1)
{

View File

@ -77,7 +77,7 @@ class RewindManager
private:
// Maximum number of states to save
static constexpr uInt32 MAX_SIZE = 100; // TODO: use a parameter here and allow user to define size in UI
static constexpr uInt32 MAX_SIZE = 10; // TODO: use a parameter here and allow user to define size in UI
OSystem& myOSystem;
StateManager& myStateManager;
@ -92,6 +92,11 @@ class RewindManager
// The goal of LinkedObjectPool is to not do any allocations at all
RewindState() { }
RewindState(const RewindState&) { }
// Output object info; used for debugging only
friend ostream& operator<<(ostream& os, const RewindState& s) {
return os << "msg: " << s.message << " cycle: " << s.cycle << " count: " << s.count;
}
};
// The linked-list to store states (internally it takes care of reducing