Remix.run Logo
sestep 4 days ago

Does std::deque support random access?

ksherlock 4 days ago | parent | next [-]

The cppreference documentation specifies "Random access - constant O(1)" (same as std::vector). There's a slight overhead from going through 2 pointers instead of 1 and keeping track of how many items are in the first bucket (so you know which bucket to check), but that's a constant and the big O don't care about constants.

mwkaufma 4 days ago | parent | prev [-]

Yes, you can see operator[] in the linked reference docs.