stack C ++ STL learning, queue, heap

1.stack realization of ideas

(1) The stack is implemented in STL deque for the bottom of the container be modified to achieve, therefore, generally referred to stack container adapter (Adapter) ( modified something interfaces, another style of pattern formation for the adapter mode ). In addition to the container as the bottom outer deque, list may be implemented as a bottom of the container stack, the usage of stack <int, list > IStack;
(2) no iterators Stack (only meet the last-out properties, so no iterators)

2. queue realization of ideas

The same stack

3.heap (used to implement a priority queue behind assistant)

(1) Implicit notation: indicates the tree structure as an array, such as a complete binary tree may be represented by an array
(2) heap is substantial complete binary one kind of a restriction condition is satisfied, the root of the heap into large and small two kinds of stack roots.
(. 3) is primarily achieved heap Vector (for implicit representation of the binary tree) and a set of algorithms to achieve heap
array form heap is (4) STL the max-heap implementation
(5) max-heap of properties (in the array shown): a first element of the array do not set aside, the data storage starts from index i is satisfied, a [i]> a [2i ] && a [i]> a [2i + 1]

4.heap algorithm

(1) push_heap algorithms: an array into the bottom, then the parent node and comparison cycles, adjustment max-heap structures.

(2) pop-heap algorithm

(3) sort-heap algorithm (HEAPSORT), make-heap algorithm
of FIG omitted, the reference heap sort ideas.

5.priority_queue (Priority Queue)

(1)定义及操作:优先队列是一个拥有权值观念的queue,允许像queue一样,即只允许低端加入,顶端取出操作;由于其带有权值,所以里面的元素自动以权值大小进行排序,权值高的,排在前面。
(2)priority_queue的底层容器为vector+heap操作(默认情况),也可以说是以max-heap为底层容器

Guess you like

Origin www.cnblogs.com/nolan24/p/10993055.html