6#include "containerAdapter.h"
11 template<
typename TYPE,
13 template <
typename>
typename SERIAL =
blocksList>
15 class prique final :
public containerAdapter<TYPE, SERIAL>
17 Callback<TYPE> compare_;
19 explicit prique(
const SERIAL<TYPE>&
serial = SERIAL<TYPE>{},
const Callback<TYPE>& compare = Callback<TYPE>{});
20 prique(
const std::initializer_list<TYPE>& lst,
const Callback<TYPE>& compare = Callback<TYPE>{});
21 prique(
const prique& other);
22 prique& operator=(
const prique& other);
23 bool operator==(
const prique& other)
const;
24 prique(prique&& other)
noexcept;
25 prique& operator=(prique&& other)
noexcept;
26 void push(
const TYPE& e);
29 [[nodiscard]] std::string className()
const override;
33 template <
typename TYPE,
template <
typename>
class Callback,
template <
typename>
typename SERIAL>
35 original::prique<TYPE, Callback, SERIAL>::prique(
const SERIAL<TYPE>& serial,
const Callback<TYPE>& compare)
36 : containerAdapter<TYPE, SERIAL>(serial), compare_(compare)
38 algorithms::heapInit(this->serial_.begin(), this->serial_.last(), this->compare_);
41 template <
typename TYPE,
template <
typename>
class Callback,
template <
typename>
typename SERIAL>
42 requires original::Compare<Callback<TYPE>, TYPE>
43 original::prique<TYPE, Callback, SERIAL>::prique(
const std::initializer_list<TYPE>& lst,
const Callback<TYPE>& compare)
44 :
prique(SERIAL<TYPE>(lst), compare) {}
46 template <
typename TYPE,
template <
typename>
class Callback,
template <
typename>
typename SERIAL>
47 requires original::Compare<Callback<TYPE>, TYPE>
48 original::prique<TYPE, Callback, SERIAL>::prique(
const prique& other)
51 template <
typename TYPE,
template <
typename>
class Callback,
template <
typename>
typename SERIAL>
52 requires original::Compare<Callback<TYPE>, TYPE>
53 auto original::prique<TYPE, Callback, SERIAL>::operator=(
const prique& other) ->
prique&
55 if (
this == &other)
return *
this;
56 this->serial_ = other.serial_;
57 compare_ = other.compare_;
61 template <
typename TYPE,
template <
typename>
class Callback,
template <
typename>
typename SERIAL>
62 requires original::Compare<Callback<TYPE>, TYPE>
63 auto original::prique<TYPE, Callback, SERIAL>::operator==(
const prique& other)
const ->
bool
65 return this->serial_ == other.serial_;
68 template <
typename TYPE,
template <
typename>
class Callback,
template <
typename>
typename SERIAL>
69 requires original::Compare<Callback<TYPE>, TYPE>
70 original::prique<TYPE, Callback, SERIAL>::prique(
prique&& other) noexcept :
prique()
72 this->operator=(std::move(other));
75 template <
typename TYPE,
template <
typename>
class Callback,
template <
typename>
typename SERIAL>
76 requires original::Compare<Callback<TYPE>, TYPE>
77 auto original::prique<TYPE, Callback, SERIAL>::operator=(
prique&& other)
noexcept ->
prique&
82 this->serial_ = std::move(other.serial_);
83 this->compare_ = std::move(other.compare_);
84 other.serial_ = SERIAL<TYPE>{};
85 other.compare_ = Callback<TYPE>{};
89 template <
typename TYPE,
template <
typename>
class Callback,
template <
typename>
typename SERIAL>
90 requires original::Compare<Callback<TYPE>, TYPE>
91 auto original::prique<TYPE, Callback, SERIAL>::push(
const TYPE& e) ->
void
93 this->serial_.pushEnd(e);
94 algorithms::heapAdjustUp(this->serial_.begin(), this->serial_.last(), this->compare_);
97 template <
typename TYPE,
template <
typename>
class Callback,
template <
typename>
typename SERIAL>
98 requires original::Compare<Callback<TYPE>, TYPE>
99 auto original::prique<TYPE, Callback, SERIAL>::pop() -> TYPE
103 algorithms::swap(this->serial_.begin(), this->serial_.last());
104 TYPE res = this->serial_.popEnd();
105 algorithms::heapAdjustDown(this->serial_.begin(), this->serial_.last(), this->serial_.begin(), compare_);
109 template <
typename TYPE,
template <
typename>
class Callback,
template <
typename>
typename SERIAL>
110 requires original::Compare<Callback<TYPE>, TYPE>
111 auto original::prique<TYPE, Callback, SERIAL>::top() const -> TYPE
113 return this->serial_.getBegin();
116 template <
typename TYPE,
template <
typename>
class Callback,
template <
typename>
typename SERIAL>
117 requires original::Compare<Callback<TYPE>, TYPE>
118 auto original::prique<TYPE, Callback, SERIAL>::className() const -> std::
string
Definition blocksList.h:10
Definition containerAdapter.h:10
Definition comparator.h:15