vsengar
vsengar

Reputation: 1

Queue STL in C++ implements the queue using Circular Arrays or Linked Lists

Since the queue can be implemented both ways, I wonder which is being used by the Queue STL.

Upvotes: 0

Views: 454

Answers (2)

Marshall Clow
Marshall Clow

Reputation: 16670

A queue is a container adaptor; it provides queue-like behavior using a different container for the underlying storage. Either deque or list are suitable for the underlying storage of a queue. See http://eel.is/c++draft/queue for all the gory details.

Neither is a circular array.

Upvotes: 2

Mauricio Ruiz
Mauricio Ruiz

Reputation: 322

Checking some documentation, the complexity of insertion for this type of container is constant, if you use a vector you can't have a constant complexity because you could need resize vector, then it use a linked list.

Upvotes: 0

Related Questions