Wiki

Clone wiki

kick / deque

The Skinny

A deque (double-ended queue) is a dynamic, sequence container. Deque is similar to vector in many respects apart from one. Adding elements to a vector may require reallocation of large blocks of memory. This is because vector requires the items to be contiguous. Deque, on the other hand, can have its items scattered throughout memory without having to perform any reallocation. This may allow the deque to perform better under certain circumstances.

Container Features

  • Sequential - Items are ordered in a linear sequence
  • Dynamic - Items can be added to either end of the deque

Template Parameters

  • T - The object type of individual items

Basic Usage

#include <iostream>
#include <kick/deque.h>

int main( int argc, const char* argv[] ){
    kick::deque<int> myDeque; 

    myDeque.push_back( 100 ); 
    myDeque.push_back( 200 ); 
    myDeque.push_back( 300 ); 

    // Outputs 100, 200, 300
    for( kick::deque<int>::iterator it = myDeque.begin(); it != myDeque.end(); ++it )
        std::cout << *it << std::end; 

}

Updated