12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #pragma once
- #include "fwd.h"
- #include "deque.h"
- #include "vector.h"
- #include "utility.h"
- #include <util/str_stl.h>
- #include <queue>
- template <class T, class S>
- class TQueue: public std::queue<T, S> {
- using TBase = std::queue<T, S>;
- public:
- using TBase::TBase;
- inline explicit operator bool() const noexcept {
- return !this->empty();
- }
- inline void clear() {
- this->c.clear();
- }
- inline S& Container() Y_LIFETIME_BOUND {
- return this->c;
- }
- inline const S& Container() const Y_LIFETIME_BOUND {
- return this->c;
- }
- };
- template <class T, class S, class C>
- class TPriorityQueue: public std::priority_queue<T, S, C> {
- using TBase = std::priority_queue<T, S, C>;
- public:
- using TBase::TBase;
- inline explicit operator bool() const noexcept {
- return !this->empty();
- }
- inline void clear() {
- this->c.clear();
- }
- inline T PopValue() {
- Y_ASSERT(!this->empty());
- auto& container = this->c;
- std::pop_heap(container.begin(), container.end(), this->comp);
- T value = std::move(container.back());
- container.pop_back();
- return value;
- }
- inline S& Container() Y_LIFETIME_BOUND {
- return this->c;
- }
- inline const S& Container() const Y_LIFETIME_BOUND {
- return this->c;
- }
- };
|