Deque IntroductionDeque is the abbreviation for "double-ended queue", which is the same as the vector of the STL, Deque is a double-ended array, and the vector is single-ended.The deque is very similar to the vector on the interface and can be
The deque bidirectional queue is a continuous linear space with bidirectional openings that can efficiently insert and delete elements at both ends of the deque, which are very similar to vectors on the interface, and list the common member
Deque is an abbreviation for the double-ended queue, similar to list, but provides an operation to insert and delete at both ends.
Appendleft inserts to the left of the list
Popleft the value to the left of the popup list
Extendleft
#include
The deque bidirectional queue is a continuous linear space with two-way openings that efficiently insert and delete elements at both ends of the deque and are very similar to vectors on the interface
Function
Describe
STL container Class C ++ STL embodies the idea of generic programming. It is broadly divided into container, iterator, and algorithm ). A container class can contain a group of objects of the same type or different types. An object of the same type
Deque (maxlen=n) creates a fixed-length queue that automatically moves except for the oldest record when a new record is added and the queue is full. 1 from collections import deque 2 d=deque ( Maxlen=3) 3 d.append (1" 4 d.append (2 5
From Deque to Std::stack,std::queue, to iOS Nsarray (cfarray) dequeThe deque double-ended queue, segmented continuous spatial data structure, is controlled by a central-controlled map (rather than a map, rather than an array), and each slot in the
There was no update for some time. Then go on with the last verse.Queue in addition to the implementation described earlier, there is a two-way queue implementation deque. This queue allows queues to be queued at the head and tail of the queue, so
Monotonous queue = double-end queue!
Let's start with the simplest problem:
Given an integer Series A (I), I = 0, 1,..., N-1 and Window Length k.
Requirements:
F (I) = max {A (I-k + 1), a (I-K + 2 ),..., A (I)}, I = 0, 1 ,..., n-1
Another
Difference between STL containers: vector list deque set map-underlying implementation
Difference between STL containers: vector list deque set Map)
In STL, the basic containers include vector, list, deque, set, and map.
Set and map are unordered
List usage
List is a double-ended linked list, so compared with vector, the advantage is that deletion and insertion are faster, but the disadvantage is that random access to data is less efficient.
Many usage of list is similar to that of vector.
Ordered container: vector, deque, list, vectordeque
1. Ordered containers: vector, deque, list
Containers share public interfaces. You only need to learn one type and use another type. Each container provides a set of different time and functions.
Deque basic operationsI. Prototype And ConstructorTypedef deque deqobj;ConstructorDeque ();Deque (Al );Deque (N );Deque (n, x );Deque (n, x, Al );Deque (first, last );Deque (first, last, Al );Ii. Operations1. Resize & clearUse resize (n) to change
# Include
// Sort Definition
# Include
// Vector Definition
# Include
// Deque Definition
# Include
// Similarly, introduce the STD namespace
Using namespace STD;
// Save with an Array
Int friends [1000];
// Save with Vector
Vector vtfriends;
//
Deque containerThe Deque container is the content in C + + STL. Deque is similar to vectors and supports random access and quick insert deletions. Deque also supports adding data from the start: Push_front ()constructor functiondeque
1, vector (continuous space storage, you can use the [] operator) can quickly access random elements, quickly inserted at the end of the element, but in the middle of the sequence randomly inserted , delete elements are slow. Also, if there is not
First, use std::d eque is better than std::vector when considering memory allocation and performance.
Deque Overview
Deque, like vectors, are the contents of the Standard Template Library, the deque is a two-terminal queue, which is very similar
Collections is a high-level container class library of Python that contains common containers outside of dict, Truple.The following describes the common deque1. The deque is a double-ended queue that can be plugged in from both ends and can be taken
In the writing of C + + program will find that STL is a good thing, reduce the amount of code, so that the code reuse rate greatly improved, reduce the burden of the program ape. There is a container, you will find that if you write a list, queue,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.