From b2af3feebd9bdbbf9ee07df3945c989c2b6a924e Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Wed, 14 Oct 2020 15:05:22 +0200 Subject: [PATCH] use Stack for MovExt too --- movext.hh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/movext.hh b/movext.hh index 63d8e94..8c29d10 100644 --- a/movext.hh +++ b/movext.hh @@ -15,31 +15,32 @@ namespace DSP { template class MovExt { - Deque window, dispenser, refill; + Deque window; + Stack dispenser, refill; EQUAL equal; COMP comp; public: TYPE operator () (TYPE input) { if (window.full()) { - if (equal(window.front(), dispenser.front())) - dispenser.pop_front(); + if (equal(window.front(), dispenser.top())) + dispenser.pop(); window.pop_front(); } window.push_back(input); - while (!refill.empty() && comp(input, refill.front())) - refill.pop_front(); - refill.push_front(input); + while (!refill.empty() && comp(input, refill.top())) + refill.pop(); + refill.push(input); if (dispenser.empty()) { while (!refill.empty()) { - dispenser.push_front(refill.front()); - refill.pop_front(); + dispenser.push(refill.top()); + refill.pop(); } - return dispenser.front(); + return dispenser.top(); } - return comp(dispenser.front(), refill.back()) ? dispenser.front() : refill.back(); + return comp(dispenser.top(), refill.first()) ? dispenser.top() : refill.first(); } };