C ++; data structure; STL-- queue

  • Define a template class in the queue <queue> header file.
  • template class queue also require two template parameters, an element type, a container type, the element type is required, the container type is optional, defaults to the type deque.

Example queue object code defines the following:
queue <int> Ql;
queue <Double> Q2;

The basic operation of the queue are:
enqueued as Example: q.push (x); x to the end of the queue.
Dequeue, as described in Example: q.pop (); pop the first element of the queue, attention, and will not return value is the pop-up element.
The first team to access elements such cases: q.front (), that is the first to be pushed into the queue elements.
Access to the tail element, as described in Example: q.back (), i.e., the final element is pressed into the queue.
Analyzing empty queue, as described in Example: q.empty (), when the queue is empty, returns true.
The number of elements in the access queue, as described in Example: q.size ()

ps: I just write queue when written about this queue <int> arr [101];

. . . . However, do not define the size! Do not define the size! STL is not defined size

Then the rest is used normally enough.

 

Queue exercises: Aha search algorithm to decrypt the QQ ---- queue

Guess you like

Origin www.cnblogs.com/juzijuziju/p/11444741.html