OutlineSTL adaptersPriority queueSTL algorithmsString streamsExamplesCase study: Text editingCOMP1522
STL's priority_queue AdapterA queuecan be specifiedqueue<T, C<T> > aQueue;Cmay be any container supporting push_back()and pop_front()The default container is vectorCould also use priority_queue<T, deque<T> > aQueue;For the best performance, use class vectoras the underlying containerEnables insertions in sorted order and deletions from frontElements are inserted in priority orderHighest-priority element will be the first to be removedMaintains sorted order via heapsortComparison of elements is performed with comparator function object less<T> by defaultCOMP1523
has intentionally blurred sections.
Sign up to view the full version.
STL's priority_queue AdapterOperations (call functions of the underlying container)push –insert element at appropriate location to maintain sorted order (calls push_back, then reorders elements with heapsort)pop –remove highest-priority element (moves top element of heap to back, then calls pop_back)top –returns reference to top element (calls front)empty –determine if the priority_queue is empty (calls empty)size –get the number of elements (calls size)Again, each common operations is implemented as an inline functionCOMP1524