A container with a constant time to access any item, pop from the front and back?

I am looking for a standard container (if one exists) that will have a constant time for:

  • access to any item by position
  • front pop element
  • Click the item back.

I can program it myself, but why bother, can it already exist in std?

+3
source share
2 answers

std :: deque is your friend. This is a double queue with random access to items.

+7
source

You can use std :: deque . It satisfies all your requirements.

  • access to any item by position

It provides random access using random iterators as well operator []

  • front pop element

pop_front()

  • .

push_back()

+3

All Articles