Is deque seriously sequence container ?
Hi I belive that deque stores data as small pieces of different arrays... I mean there are different small arrays which are connected through linkedlist. This provides quick insertion at beginning and end in constant time. Is above information true ? If yes, I am wondering why random access is constant O(1) even though linked list is there?
7/24/2021 3:38:03 PMKetan Lalcheta
1 AnswerNew Answer
The dequeue class is a container class. I have no idea what a sequence container is. "Specific libraries may implement deques in different ways, generally as some form of dynamic array. But in any case, they allow for the individual elements to be accessed directly through random access iterators, with storage handled automatically by expanding and contracting the container as needed." http://www.cplusplus.com/reference/deque/deque/ If you want to see how your specific compiler library implements the solution examine the library source code.