Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Priority queue
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Libraries == A priority queue is often considered to be a "[[container (abstract data type)|container data structure]]". The [[Standard Template Library]] (STL), and the [[C++]] 1998 standard, specifies [https://en.cppreference.com/w/cpp/container/priority_queue std::priority_queue] as one of the STL [[container (programming)|container]] [[adaptor (programming)|adaptor]] [[Template (programming)|class template]]s. However, it does not specify how two elements with same priority should be served, and indeed, common implementations will not return them according to their order in the queue. It implements a max-priority-queue, and has three parameters: a comparison object for sorting such as a function object (defaults to less<T> if unspecified), the underlying container for storing the data structures (defaults to std::vector<T>), and two iterators to the beginning and end of a sequence. Unlike actual STL containers, it does not allow [[Iterator|iteration]] of its elements (it strictly adheres to its abstract data type definition). STL also has utility functions for manipulating another random-access container as a binary max-heap. The [[Boost (C++ libraries)|Boost libraries]] also have an implementation in the library heap. Python's [https://docs.python.org/library/heapq.html heapq] module implements a binary min-heap on top of a list. [[Java (programming language)|Java]]'s library contains a {{Javadoc:SE|java/util|PriorityQueue}} class, which implements a min-priority-queue as a binary heap. [[.NET]]'s library contains a [https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.priorityqueue-2?view=net-6.0 PriorityQueue] class, which implements an array-backed, quaternary min-heap. [[Scala (programming language)|Scala]]'s library contains a [https://www.scala-lang.org/api/current/scala/collection/mutable/PriorityQueue.html PriorityQueue] class, which implements a max-priority-queue. [[Go (programming language)|Go]]'s library contains a [http://golang.org/pkg/container/heap/ container/heap] module, which implements a min-heap on top of any compatible data structure. The [[Standard PHP Library]] extension contains the class [http://us2.php.net/manual/en/class.splpriorityqueue.php SplPriorityQueue]. Apple's [[Core Foundation]] framework contains a [https://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFBinaryHeapRef/Reference/reference.html CFBinaryHeap] structure, which implements a min-heap.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)