11#ifndef INCLUDED_BSLSTL_PRIORITYQUEUE_CPP03
12#define INCLUDED_BSLSTL_PRIORITYQUEUE_CPP03
63#ifdef COMPILING_BSLSTL_PRIORITYQUEUE_H
81 class CONTAINER = vector<VALUE>,
82 class COMPARATOR = std::less<typename CONTAINER::value_type> >
85#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
95 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
101 typedef typename CONTAINER::value_type
value_type;
102 typedef typename CONTAINER::reference
reference;
104 typedef typename CONTAINER::size_type
size_type;
120 BloombergLP::bslma::UsesBslmaAllocator,
121 BloombergLP::bslma::UsesBslmaAllocator<container_type>::value);
141 priority_queue(
const COMPARATOR& comparator,
const CONTAINER& container);
148 const COMPARATOR& comparator,
149 BloombergLP::bslmf::MovableRef<CONTAINER> container);
158 template <
class INPUT_ITERATOR>
167 template <
class INPUT_ITERATOR>
170 const COMPARATOR& comparator,
171 const CONTAINER& container);
179 template <
class INPUT_ITERATOR>
181 INPUT_ITERATOR first,
183 const COMPARATOR& comparator,
184 BloombergLP::bslmf::MovableRef<CONTAINER> container);
194 priority_queue(BloombergLP::bslmf::MovableRef<priority_queue> original);
203 template <
class ALLOCATOR>
208 ALLOCATOR>::type * = 0);
216 template <
class ALLOCATOR>
218 const ALLOCATOR& basicAllocator,
221 ALLOCATOR>::type * = 0);
228 template <
class ALLOCATOR>
230 const CONTAINER& container,
231 const ALLOCATOR& basicAllocator,
234 ALLOCATOR>::type * = 0);
241 template <
class ALLOCATOR>
243 BloombergLP::bslmf::MovableRef<CONTAINER> container,
244 const ALLOCATOR& basicAllocator,
247 ALLOCATOR>::type * = 0);
255 template <
class ALLOCATOR>
257 const ALLOCATOR& basicAllocator,
260 ALLOCATOR>::type * = 0);
268 template <
class ALLOCATOR>
270 BloombergLP::bslmf::MovableRef<priority_queue> original,
271 const ALLOCATOR& basicAllocator,
274 ALLOCATOR>::type * = 0);
287 BloombergLP::bslmf::MovableRef<priority_queue> rhs)
296 void push(BloombergLP::bslmf::MovableRef<value_type> value);
298#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
301#ifndef BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT
302#define BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT 10
304#ifndef BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A
305#define BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT
307#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 0
311#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 1
312 template <
class Args_01>
316#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 2
317 template <
class Args_01,
323#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 3
324 template <
class Args_01,
332#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 4
333 template <
class Args_01,
343#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 5
344 template <
class Args_01,
356#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 6
357 template <
class Args_01,
371#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 7
372 template <
class Args_01,
388#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 8
389 template <
class Args_01,
407#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 9
408 template <
class Args_01,
428#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_A >= 10
429 template <
class Args_01,
454 template <
class... Args>
466 bsl::is_nothrow_swappable<CONTAINER>::value &&
467 bsl::is_nothrow_swappable<COMPARATOR>::value);
489#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
497 class = bsl::enable_if_t<!bsl::IsStdAllocator_v<CONTAINER>>
499priority_queue(COMPARATOR, CONTAINER)
500 -> priority_queue<typename CONTAINER::value_type, CONTAINER, COMPARATOR>;
510 class = bsl::enable_if_t<bsl::uses_allocator_v<CONTAINER, ALLOCATOR>>
512priority_queue(COMPARATOR, CONTAINER, ALLOCATOR)
513 -> priority_queue<typename CONTAINER::value_type, CONTAINER, COMPARATOR>;
518 class INPUT_ITERATOR,
520 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>
522priority_queue(INPUT_ITERATOR, INPUT_ITERATOR)
523 -> priority_queue<VALUE>;
530 class INPUT_ITERATOR,
534 typename BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>
536priority_queue(INPUT_ITERATOR, INPUT_ITERATOR, COMPARATOR, CONTAINER)
537 -> priority_queue<VALUE, CONTAINER, COMPARATOR>;
544template <
class VALUE,
class CONTAINER,
class COMPARATOR>
545void swap(priority_queue<VALUE, CONTAINER, COMPARATOR>& a,
546 priority_queue<VALUE, CONTAINER, COMPARATOR>& b)
558template <
class VALUE,
class CONTAINER,
class COMPARATOR>
564template <
class VALUE,
class CONTAINER,
class COMPARATOR>
567 const COMPARATOR& comparator)
572template <
class VALUE,
class CONTAINER,
class COMPARATOR>
574priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
575 const COMPARATOR& comparator,
576 const CONTAINER& container)
580 std::make_heap(c.begin(), c.end(), comp);
583template <
class VALUE,
class CONTAINER,
class COMPARATOR>
585priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
586 const COMPARATOR& comparator,
587 BloombergLP::bslmf::MovableRef<CONTAINER> container)
588: c(MoveUtil::move(container))
591 std::make_heap(c.begin(), c.end(), comp);
594template <
class VALUE,
class CONTAINER,
class COMPARATOR>
595template <
class INPUT_ITERATOR>
597priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
598 INPUT_ITERATOR first,
601 c.insert(c.end(), first, last);
602 std::make_heap(c.begin(), c.end(), comp);
605template <
class VALUE,
class CONTAINER,
class COMPARATOR>
606template <
class INPUT_ITERATOR>
608priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
609 INPUT_ITERATOR first,
611 const COMPARATOR& comparator,
612 const CONTAINER& container)
616 c.insert(c.end(), first, last);
617 std::make_heap(c.begin(), c.end(), comp);
620template <
class VALUE,
class CONTAINER,
class COMPARATOR>
621template <
class INPUT_ITERATOR>
623priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
624 INPUT_ITERATOR first,
626 const COMPARATOR& comparator,
627 BloombergLP::bslmf::MovableRef<CONTAINER> container)
628: c(MoveUtil::move(container))
631 c.insert(c.end(), first, last);
632 std::make_heap(c.begin(), c.end(), comp);
635template <
class VALUE,
class CONTAINER,
class COMPARATOR>
637priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
638 const priority_queue& original)
644template <
class VALUE,
class CONTAINER,
class COMPARATOR>
646priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
647 BloombergLP::bslmf::MovableRef<priority_queue> original)
648: c(MoveUtil::move(MoveUtil::access(original).c))
649, comp(MoveUtil::access(original).comp)
653template <
class VALUE,
class CONTAINER,
class COMPARATOR>
654template <
class ALLOCATOR>
656priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
657 const ALLOCATOR& basicAllocator,
666template <
class VALUE,
class CONTAINER,
class COMPARATOR>
667template <
class ALLOCATOR>
669priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
670 const COMPARATOR& comparator,
671 const ALLOCATOR& basicAllocator,
680template <
class VALUE,
class CONTAINER,
class COMPARATOR>
681template <
class ALLOCATOR>
683priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
684 const COMPARATOR& comparator,
685 const CONTAINER& container,
686 const ALLOCATOR& basicAllocator,
690: c(container, basicAllocator)
693 std::make_heap(c.begin(), c.end(), comp);
696template <
class VALUE,
class CONTAINER,
class COMPARATOR>
697template <
class ALLOCATOR>
699priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
700 const COMPARATOR& comparator,
701 BloombergLP::bslmf::MovableRef<CONTAINER> container,
702 const ALLOCATOR& basicAllocator,
706: c(MoveUtil::move(container), basicAllocator)
709 std::make_heap(c.begin(), c.end(), comp);
712template <
class VALUE,
class CONTAINER,
class COMPARATOR>
713template <
class ALLOCATOR>
715priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
716 const priority_queue& original,
717 const ALLOCATOR& basicAllocator,
721: c(original.c, basicAllocator)
726template <
class VALUE,
class CONTAINER,
class COMPARATOR>
727template <
class ALLOCATOR>
729priority_queue<VALUE, CONTAINER, COMPARATOR>::priority_queue(
730 BloombergLP::bslmf::MovableRef<priority_queue> original,
731 const ALLOCATOR& basicAllocator,
735: c(MoveUtil::move(MoveUtil::access(original).c), basicAllocator)
736, comp(MoveUtil::access(original).comp)
741template <
class VALUE,
class CONTAINER,
class COMPARATOR>
743priority_queue<VALUE, CONTAINER, COMPARATOR>&
744priority_queue<VALUE, CONTAINER, COMPARATOR>::operator=(
745 const priority_queue& rhs)
752template <
class VALUE,
class CONTAINER,
class COMPARATOR>
754priority_queue<VALUE, CONTAINER, COMPARATOR>&
755priority_queue<VALUE, CONTAINER, COMPARATOR>::operator=(
756 BloombergLP::bslmf::MovableRef<priority_queue> rhs)
759 c = MoveUtil::move(MoveUtil::access(rhs).c);
760 comp = MoveUtil::access(rhs).comp;
764template <
class VALUE,
class CONTAINER,
class COMPARATOR>
766void priority_queue<VALUE, CONTAINER, COMPARATOR>::push(
767 const value_type& value)
770 std::push_heap(c.begin(), c.end(), comp);
773template <
class VALUE,
class CONTAINER,
class COMPARATOR>
775void priority_queue<VALUE, CONTAINER, COMPARATOR>::push(
776 BloombergLP::bslmf::MovableRef<value_type> value)
778 c.push_back(MoveUtil::move(value));
779 std::push_heap(c.begin(), c.end(), comp);
782#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
785#ifndef BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT
786#define BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT 10
788#ifndef BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B
789#define BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT
791#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 0
792template <
class VALUE,
class CONTAINER,
class COMPARATOR>
794void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
798 std::push_heap(c.begin(), c.end(), comp);
802#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 1
803template <
class VALUE,
class CONTAINER,
class COMPARATOR>
804template <
class Args_01>
806void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
810 std::push_heap(c.begin(), c.end(), comp);
814#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 2
815template <
class VALUE,
class CONTAINER,
class COMPARATOR>
816template <
class Args_01,
819void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
825 std::push_heap(c.begin(), c.end(), comp);
829#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 3
830template <
class VALUE,
class CONTAINER,
class COMPARATOR>
831template <
class Args_01,
835void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
843 std::push_heap(c.begin(), c.end(), comp);
847#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 4
848template <
class VALUE,
class CONTAINER,
class COMPARATOR>
849template <
class Args_01,
854void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
864 std::push_heap(c.begin(), c.end(), comp);
868#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 5
869template <
class VALUE,
class CONTAINER,
class COMPARATOR>
870template <
class Args_01,
876void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
888 std::push_heap(c.begin(), c.end(), comp);
892#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 6
893template <
class VALUE,
class CONTAINER,
class COMPARATOR>
894template <
class Args_01,
901void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
915 std::push_heap(c.begin(), c.end(), comp);
919#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 7
920template <
class VALUE,
class CONTAINER,
class COMPARATOR>
921template <
class Args_01,
929void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
945 std::push_heap(c.begin(), c.end(), comp);
949#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 8
950template <
class VALUE,
class CONTAINER,
class COMPARATOR>
951template <
class Args_01,
960void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
978 std::push_heap(c.begin(), c.end(), comp);
982#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 9
983template <
class VALUE,
class CONTAINER,
class COMPARATOR>
984template <
class Args_01,
994void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
1014 std::push_heap(c.begin(), c.end(), comp);
1018#if BSLSTL_PRIORITYQUEUE_VARIADIC_LIMIT_B >= 10
1019template <
class VALUE,
class CONTAINER,
class COMPARATOR>
1020template <
class Args_01,
1031void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
1053 std::push_heap(c.begin(), c.end(), comp);
1060template <
class VALUE,
class CONTAINER,
class COMPARATOR>
1061template <
class... Args>
1063void priority_queue<VALUE, CONTAINER, COMPARATOR>::emplace(
1067 std::push_heap(c.begin(), c.end(), comp);
1072template <
class VALUE,
class CONTAINER,
class COMPARATOR>
1074void priority_queue<VALUE, CONTAINER, COMPARATOR>::pop()
1076 std::pop_heap(c.begin(), c.end(), comp);
1080template <
class VALUE,
class CONTAINER,
class COMPARATOR>
1082void priority_queue<VALUE, CONTAINER, COMPARATOR>::swap(priority_queue& other)
1084 bsl::is_nothrow_swappable<CONTAINER>::value &&
1085 bsl::is_nothrow_swappable<COMPARATOR>::value)
1087 BloombergLP::bslalg::SwapUtil::swap(&c, &other.c);
1088 BloombergLP::bslalg::SwapUtil::swap(&comp, &other.comp);
1092template <
class VALUE,
class CONTAINER,
class COMPARATOR>
1094bool priority_queue<VALUE, CONTAINER, COMPARATOR>::empty()
const
1099template <
class VALUE,
class CONTAINER,
class COMPARATOR>
1101typename priority_queue<VALUE, CONTAINER, COMPARATOR>::size_type
1102priority_queue<VALUE, CONTAINER, COMPARATOR>::size()
const
1107template <
class VALUE,
class CONTAINER,
class COMPARATOR>
1109typename priority_queue<VALUE, CONTAINER, COMPARATOR>::const_reference
1110priority_queue<VALUE, CONTAINER, COMPARATOR>::top()
const
1116template <
class VALUE,
class CONTAINER,
class COMPARATOR>
1117void swap(priority_queue<VALUE, CONTAINER, COMPARATOR>& a,
1118 priority_queue<VALUE, CONTAINER, COMPARATOR>& b)
1127# error Not valid except when included from bslstl_priorityqueue.h
#define BSLMF_NESTED_TRAIT_DECLARATION_IF(t_TYPE, t_TRAIT, t_COND)
Definition bslmf_nestedtraitdeclaration.h:243
size_type size() const
Definition bslstl_priorityqueue.h:1018
void emplace(Args &&... args)
Definition bslstl_priorityqueue.h:981
void pop()
Definition bslstl_priorityqueue.h:990
void swap(priority_queue &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(bsl bool empty() const
Definition bslstl_priorityqueue.h:671
COMPARATOR value_compare
Definition bslstl_priorityqueue.h:447
CONTAINER::reference reference
Definition bslstl_priorityqueue.h:449
COMPARATOR comp
Definition bslstl_priorityqueue.h:459
CONTAINER::size_type size_type
Definition bslstl_priorityqueue.h:451
priority_queue()
Definition bslstl_priorityqueue.h:755
CONTAINER::const_reference const_reference
Definition bslstl_priorityqueue.h:450
CONTAINER c
Definition bslstl_priorityqueue.h:455
CONTAINER::value_type value_type
Definition bslstl_priorityqueue.h:448
void push(const value_type &value)
Definition bslstl_priorityqueue.h:961
const_reference top() const
Definition bslstl_priorityqueue.h:1026
CONTAINER container_type
Definition bslstl_priorityqueue.h:446
priority_queue & operator=(const priority_queue &rhs)
Definition bslstl_priorityqueue.h:939
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
static const t_TYPE value
Definition bslmf_integralconstant.h:258
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(...)
Definition bsls_keyword.h:634
void swap(OptionValue &a, OptionValue &b)
Definition bdlb_printmethods.h:283
Definition bslmf_usesallocator.h:165