![]() ![]() Accessing elements in a priority_queue has constant complexity. The underlying container class is encapsulated within the container adaptor, which exposes only the limited set of the sequence container member functions as a public interface.Īdding elements to and removing elements from a priority_queue both have logarithmic complexity. Suitable underlying container classes for priority_queue include deque Class and the default vector Class or any other sequence container that supports the operations of front, push_back, and pop_back and a random-access iterator. On a more technical note, the comparison function is a binary predicate that induces a strict weak ordering in the standard mathematical sense. This results in an ordering between the nonequivalent elements. In general, the elements need be merely less than comparable to establish this order: so that, given any two elements, it may be determined either that they're equivalent (in the sense that neither is less than the other) or that one is less than the other. The priority_queue orders the sequence it controls by calling a stored function object of class Traits. The Type must be assignable, so that it's possible to copy objects of that type and to assign values to variables of that type. The elements of class Type stipulated in the first template parameter of a queue object are synonymous with value_type and must match the type of element in the underlying container class Container stipulated by the second template parameter. ![]() This argument is optional and the binary predicate less is the default value. The type that provides a function object that can compare two element values as sort keys to determine their relative order in the priority_queue. The type of the underlying container used to implement the priority_queue. The element data type to be stored in the priority_queue. New elements can be added to the priority_queue and the top element of the priority_queue can be inspected or removed. A template container adaptor class that provides a restriction of functionality limiting access to the top element of some underlying container type, which is always the largest or of the highest priority. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |