76 template <
class T,
class CompareT = std::less<T>>
81 using container_type = std::vector<T>;
82 using compare = CompareT;
83 using iterator =
typename container_type::iterator;
84 using const_iterator =
typename container_type::const_iterator;
92 template <
class InputIt>
101 PONCA_MULTIARCH
inline iterator begin();
102 PONCA_MULTIARCH
inline const_iterator begin()
const;
103 PONCA_MULTIARCH
inline const_iterator cbegin()
const;
105 PONCA_MULTIARCH
inline iterator end();
106 PONCA_MULTIARCH
inline const_iterator end()
const;
107 PONCA_MULTIARCH
inline const_iterator cend()
const;
111 PONCA_MULTIARCH
inline const T& top()
const;
112 PONCA_MULTIARCH
inline const T& bottom()
const;
114 PONCA_MULTIARCH
inline T& top();
115 PONCA_MULTIARCH
inline T& bottom();
119 PONCA_MULTIARCH
inline bool empty()
const;
120 PONCA_MULTIARCH
inline bool full()
const;
121 PONCA_MULTIARCH
inline size_t size()
const;
122 PONCA_MULTIARCH
inline size_t capacity()
const;
126 PONCA_MULTIARCH
inline bool push(
const T& value);
127 PONCA_MULTIARCH
inline bool push(T&& value);
129 PONCA_MULTIARCH
inline void pop();
131 PONCA_MULTIARCH
inline void reserve(
int capacity);
133 PONCA_MULTIARCH
inline void clear();
137 PONCA_MULTIARCH
inline const container_type& container()
const;
152 template <
class T,
class Cmp>
157 template <
class T,
class Cmp>
158 limited_priority_queue<T, Cmp>::limited_priority_queue(
const this_type& other)
159 : m_c(other.m_c), m_comp(other.m_comp), m_size(other.m_size)
163 template <
class T,
class Cmp>
164 limited_priority_queue<T, Cmp>::limited_priority_queue(
int capacity) : m_c(capacity), m_comp(), m_size(0)
168 template <
class T,
class Cmp>
169 template <
class InputIt>
170 limited_priority_queue<T, Cmp>::limited_priority_queue(
int capacity, InputIt first, InputIt last)
171 : m_c(capacity), m_comp(), m_size(0)
173 for (InputIt it = first; it < last; ++it)
179 template <
class T,
class Cmp>
180 limited_priority_queue<T, Cmp>::~limited_priority_queue()
184 template <
class T,
class Cmp>
185 limited_priority_queue<T, Cmp>& limited_priority_queue<T, Cmp>::operator=(
const this_type& other)
188 m_comp = other.m_comp;
189 m_size = other.m_size;
195 template <
class T,
class Cmp>
196 typename limited_priority_queue<T, Cmp>::iterator limited_priority_queue<T, Cmp>::begin()
201 template <
class T,
class Cmp>
202 typename limited_priority_queue<T, Cmp>::const_iterator limited_priority_queue<T, Cmp>::begin()
const
207 template <
class T,
class Cmp>
208 typename limited_priority_queue<T, Cmp>::const_iterator limited_priority_queue<T, Cmp>::cbegin()
const
213 template <
class T,
class Cmp>
214 typename limited_priority_queue<T, Cmp>::iterator limited_priority_queue<T, Cmp>::end()
216 return m_c.begin() + m_size;
219 template <
class T,
class Cmp>
220 typename limited_priority_queue<T, Cmp>::const_iterator limited_priority_queue<T, Cmp>::end()
const
222 return m_c.begin() + m_size;
225 template <
class T,
class Cmp>
226 typename limited_priority_queue<T, Cmp>::const_iterator limited_priority_queue<T, Cmp>::cend()
const
228 return m_c.cbegin() + m_size;
233 template <
class T,
class Cmp>
234 const T& limited_priority_queue<T, Cmp>::top()
const
239 template <
class T,
class Cmp>
240 const T& limited_priority_queue<T, Cmp>::bottom()
const
242 return m_c[m_size - 1];
245 template <
class T,
class Cmp>
246 T& limited_priority_queue<T, Cmp>::top()
251 template <
class T,
class Cmp>
252 T& limited_priority_queue<T, Cmp>::bottom()
254 return m_c[m_size - 1];
259 template <
class T,
class Cmp>
260 bool limited_priority_queue<T, Cmp>::empty()
const
265 template <
class T,
class Cmp>
266 bool limited_priority_queue<T, Cmp>::full()
const
268 return m_size == capacity();
271 template <
class T,
class Cmp>
272 size_t limited_priority_queue<T, Cmp>::size()
const
277 template <
class T,
class Cmp>
278 size_t limited_priority_queue<T, Cmp>::capacity()
const
285 template <
class T,
class Cmp>
286 bool limited_priority_queue<T, Cmp>::push(
const T& value)
299 iterator it = std::upper_bound(begin(), end(), value, m_comp);
313 std::copy_backward(it, end() - 1, end());
318 std::copy_backward(it, end(), end() + 1);
328 template <
class T,
class Cmp>
329 bool limited_priority_queue<T, Cmp>::push(T&& value)
335 m_c.front() = std::move(value);
342 iterator it = std::upper_bound(begin(), end(), std::move(value), m_comp);
347 *it = std::move(value);
356 std::copy_backward(it, end() - 1, end());
357 *it = std::move(value);
361 std::copy_backward(it, end(), end() + 1);
362 *it = std::move(value);
371 template <
class T,
class Cmp>
372 void limited_priority_queue<T, Cmp>::pop()
377 template <
class T,
class Cmp>
378 void limited_priority_queue<T, Cmp>::reserve(
int capacity)
380 if (m_size > capacity)
384 m_c.resize(capacity);
387 template <
class T,
class Cmp>
388 void limited_priority_queue<T, Cmp>::clear()
395 template <
class T,
class Cmp>
396 const typename limited_priority_queue<T, Cmp>::container_type& limited_priority_queue<T, Cmp>::container()
const