stl::deque is implemented as an array of arrays; this questions explains how it is implemented in most cases; My question is: is it possible to set the size of the inner array (or chunk) ? It seems to be an implementation detail that is impossible to manipulate. Are there implementations that allow to set the size of inner array?
Thanks Pinky for the answer: in libstdc++ (gcc stl) we have
#ifndef _GLIBCXX_DEQUE_BUF_SIZE
#define _GLIBCXX_DEQUE_BUF_SIZE 512
#endif
inline size_t
__deque_buf_size(size_t __size)
{ return (__size < _GLIBCXX_DEQUE_BUF_SIZE
? size_t(_GLIBCXX_DEQUE_BUF_SIZE / __size) : size_t(1)); }
So that the size of the inner node is set by defining _GLIBCXX_DEQUE_BUF_SIZE (#define _GLIBCXX_DEQUE_BUF_SIZE 4096 - if you want an inner node of this size) before including the deque header (for stdc++)
__deque_buf_size even has some doxygen documentation, so that this solution is documented (even though it is not covered by the standard).
/**
* @brief This function controls the size of memory nodes.
* @param __size The size of an element.
* @return The number (not byte size) of elements per node.
*
* This function started off as a compiler kludge from SGI, but
* seems to be a useful wrapper around a repeated constant
* expression. The @b 512 is tunable (and no other code needs to
* change), but no investigation has been done since inheriting the
* SGI code. Touch _GLIBCXX_DEQUE_BUF_SIZE only if you know what
* you are doing, however: changing it breaks the binary
* compatibility!!
*/