title: STL deque accessing by index is O(1)?
body: <p>I've read that accessing elements by position index can be done in constant time in a STL deque. As far as I know, elements in a deque may be stored in several non-contiguous locations, eliminating safe access through pointer arithmetic. For example:</p>
  
  <p>abc->defghi->jkl->mnop</p>
  
  <p>The elements of the deque above consists of a single character. The set of characters in one group indicate it is allocated in contiguous memory (e.g. abc is in a single block of memory, defhi is located in another block of memory, etc.). Can anyone explain how accessing by position index can be done in constant time, especially if the element to be accessed is in the second block? Or does a deque have a pointer to the group of blocks? </p>
  
  <p>Update: Or is there any other common implementation for a deque?</p>