src/ds/mono_stack/lib.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "../../util/alias/others/lib.hpp" | ||
| 4 | |||
| 5 | namespace tifa_libs { | ||
| 6 | |||
| 7 | template <class T, class Comp = std::less<T>> | ||
| 8 | class mono_stack { | ||
| 9 | static CEXP Comp compare{}; | ||
| 10 | |||
| 11 | vec<T> s; | ||
| 12 | |||
| 13 | public: | ||
| 14 | 316116 | CEXP void pop_greater(cT_(T) x) NE { | |
| 15 |
6/6✓ Branch 2 taken 631900 times.
✓ Branch 3 taken 140 times.
✓ Branch 6 taken 315924 times.
✓ Branch 7 taken 315976 times.
✓ Branch 8 taken 315924 times.
✓ Branch 9 taken 316116 times.
|
632040 | while (!s.empty() && compare(x, s.back())) s.pop_back(); |
| 16 | 316116 | } | |
| 17 | 316116 | CEXP void push_nocheck(cT_(T) x) NE { s.push_back(x); } | |
| 18 | CEXP void push(cT_(T) x) NE { pop_greater(x), s.push_back(x); } | ||
| 19 | ND CEXP T CR top() CNE { return s.back(); } | ||
| 20 | 316116 | ND CEXP u32 size() CNE { return (u32)s.size(); } | |
| 21 | }; | ||
| 22 | |||
| 23 | } // namespace tifa_libs | ||
| 24 |