Page Speed Optimization Libraries  1.2.24.1
Public Member Functions | Static Public Member Functions
VectorDeque< T > Class Template Reference

NET_INSTAWEB_UTIL_PUBLIC_VECTOR_DEQUE_H_. More...

#include "vector_deque.h"

List of all members.

Public Member Functions

 VectorDeque ()
void push_back (T value)
void push_front (T value)
void pop_back ()
void pop_front ()
back () const
front () const
size_t capacity () const
size_t size () const
bool empty () const

Static Public Member Functions

static size_t initial_capacity ()

Detailed Description

template<class T>
class VectorDeque< T >

NET_INSTAWEB_UTIL_PUBLIC_VECTOR_DEQUE_H_.

for size_t for memcpy Simple implementation of deque using a vector which we double in capacity whenever we need to make room. This alternative to std::deque is perhaps a little more fragmentious to memory allocators, but will frequently allocate much less overall memory.

In particular, I found, using top, that std::deque allocates 688 bytes to construct a deque containing 4 pointers on a 64-bit system. In this implementation the cost is 64 bytes plus malloc overhead: 3 size_t integers and a pointer to an allocated array, plus the the 4 pointers in the allocated array.

This implementation lacks iterators, many std::deque methods, and the ability to work with value-semantics for the contained object. These could all be added without changing the design.

Please do not instantiate this class with an object that cannot be copied with memcpy. Pointers, integers, and floats are fine, as well as simple structs of those.


Constructor & Destructor Documentation

template<class T>
VectorDeque< T >::VectorDeque ( ) [inline]

Constructor provides a small initial allocation, rather than constructing with zero capacity, based on expected usage patterns.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines