Summary:
A question about the container adapter.
Just beginning to contact the container adapter, always feel strange, think superfluous, handy search, originally I was not alone at this point:
Use of STL container adapters
One of the guys said well, here's a quote:
1 adapter intended to be a receptacle, adapter, the meaning of the coupling. Now I need a stack structure, we can use deque to do, only one end of the element insertion and ejection, the other end does not move. This means that deque can be used as a stack structure, but it does not directly meet your requirements, because you cannot prevent others from moving your stuff on the other end. You need to wrap it up and make some restrictions so that it can only be inserted and deleted at one end. That means you have to provide a "socket", the "socket" on the deque, the other end in your program, you can use the stack structure. And the stack is the "socket" that connects the Deque and your program. On the surface you are using a stack, in fact you are using the "socket" of the stack to use Deque (because the stack is completely implemented with deque, it does not have anything else, it is just a layer of packaging on the deque, the equivalent of a "socket" function). Therefore, classes such as stack, queue, and priority_queue are generally referred to as container adapters, and they are simply adaptations of the basic container type (vector,dequeue,list). 2 Actually, this is also the basic idea of the adapter pattern: to convert the interface of a class into another interface that the customer wants. The adapter mode makes it possible for those classes that would otherwise not work together because of incompatible interfaces to work together. In other words, a "socket" class is provided on the interface of a class to make it the interface you want to use.
C + + sequential container Learning-Container Adapter