Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/container/vector"

From cppreference.com
< cpp‎ | container
m (Text replace - "/sidebar" to "/navbar")
(vector<bool> was an orphan!)
Line 11: Line 11:
  
 
{{tt|std::vector}} meets the requirements of {{concept|Container}}, {{concept|AllocatorAwareContainer}}, {{concept|SequenceContainer}} and {{concept|ReversibleContainer}}.
 
{{tt|std::vector}} meets the requirements of {{concept|Container}}, {{concept|AllocatorAwareContainer}}, {{concept|SequenceContainer}} and {{concept|ReversibleContainer}}.
 +
 +
===Specializations===
 +
The standard library provides a specialization of {{tt|std::vector}} for the type {{c|bool}}, which is optimized for space efficiency.
 +
{{dcl list begin}}
 +
{{dcl list template | cpp/container/dcl list vector_bool}}
 +
{{dcl list end}}
  
 
===Member types===
 
===Member types===

Revision as of 04:48, 19 June 2012

 
 
 
 
Defined in header <vector>
template<

    class T,
    class Allocator = std::allocator<T>

> class vector;

std::vector is a container that supports fast random access to the elements and fast insertion or removal of elements at the end of the container. Fast element insertion or removal in the middle of the container is not supported. It is implemented as an contiguous array, which means that pointer arithmetic is fully supported, and a pointer to an element of a vector may be passed to any C function that expects a pointer to an element of an array.

std::vector meets the requirements of Template:concept, Template:concept, Template:concept and Template:concept.

Contents

Specializations

The standard library provides a specialization of std::vector for the type bool, which is optimized for space efficiency.

Template:cpp/container/dcl list vector bool

Member types

Template:cpp/container/dcl list value typeTemplate:cpp/container/dcl list allocator typeTemplate:cpp/container/dcl list size typeTemplate:cpp/container/dcl list difference typeTemplate:cpp/container/dcl list referenceTemplate:cpp/container/dcl list const referenceTemplate:cpp/container/dcl list pointerTemplate:cpp/container/dcl list const pointerTemplate:cpp/container/dcl list iteratorTemplate:cpp/container/dcl list const iteratorTemplate:cpp/container/dcl list reverse iteratorTemplate:cpp/container/dcl list const reverse iterator
Member type Definition

Member functions

Template:cpp/container/dcl list constructorTemplate:cpp/container/dcl list destructorTemplate:cpp/container/dcl list operator=Template:cpp/container/dcl list assignTemplate:cpp/container/dcl list get allocatorTemplate:cpp/container/dcl list atTemplate:cpp/container/dcl list operator atTemplate:cpp/container/dcl list frontTemplate:cpp/container/dcl list backTemplate:cpp/container/dcl list dataTemplate:cpp/container/dcl list beginTemplate:cpp/container/dcl list endTemplate:cpp/container/dcl list rbeginTemplate:cpp/container/dcl list rendTemplate:cpp/container/dcl list emptyTemplate:cpp/container/dcl list sizeTemplate:cpp/container/dcl list max sizeTemplate:cpp/container/dcl list reserveTemplate:cpp/container/dcl list capacityTemplate:cpp/container/dcl list shrink to fitTemplate:cpp/container/dcl list clearTemplate:cpp/container/dcl list insertTemplate:cpp/container/dcl list emplaceTemplate:cpp/container/dcl list eraseTemplate:cpp/container/dcl list push backTemplate:cpp/container/dcl list emplace backTemplate:cpp/container/dcl list pop backTemplate:cpp/container/dcl list resizeTemplate:cpp/container/dcl list swap
Element access
Iterators
Capacity
Modifiers

Non-member functions

Template:cpp/container/dcl list operator cmpTemplate:cpp/container/dcl list swap2