[ Web Proxy ]
URL:
Viewing: https://fr.cppreference.com/cpp/container/vector [Back]  [Original]

std::vector cppreference.com
cppreference.com
Espaces de noms
Variantes

std::vector

De cppreference.com
 
 
 
std::vector
Les fonctions membres
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
vector::vector
vector::~vector
vector::operator=
vector::assign
vector::get_allocator
Elment d'accs
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
vector::at
vector::operator[]
vector::front
vector::back
vector::data (C++11)
Les itrateurs
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
vector::begin
vector::cbegin

(C++11)
vector::end
vector::cend

(C++11)
vector::rbegin
vector::crbegin

(C++11)
vector::rend
vector::crend

(C++11)
Capacit
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
vector::empty
vector::size
vector::max_size
vector::reserve
vector::capacity
vector::shrink_to_fit (C++11)
Modificateurs
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
vector::clear
vector::insert
vector::emplace (C++11)
vector::erase
vector::push_back
vector::emplace_back (C++11)
vector::pop_back
vector::resize
vector::swap
 
<tbody> </tbody>
Dclar dans l'en-tte <vector>
template< class T, class Allocator = std::allocator<T> > class vector;

std::vector est un conteneur squentiel qui encapsule les tableaux de taille dynamique .

Les lments sont stocks de faon contige, ce qui signifie que les lments sont accessibles non seulement via les itrateurs, mais aussi partir des pointeurs classiques sur un lment. Cela signifie qu'un pointeur sur un lment d'un vector peut tre pass une fonction qui attend un pointeur sur un lment d'un tableau.

Le stockage du vector est pris en charge automatiquement, pouvant tre augment ou diminu au besoin. Les vector occupent gnralement plus d'espace que les tableaux statiques, du fait que de la mmoire supplmentaire est alloue pour anticiper un accroissement futur. Ainsi, un vector n'a pas besoin de r-allouer la mmoire chaque fois qu'un lment est insr, mais seulement lorsque la mmoire additionnelle est puise. La quantit totale de mmoire alloue peut tre obtenue en utilisant la fonction capacity(). La mmoire additionnelle peut tre rendue au systme via un appel shrink_to_fit().

Les r-allocations sont gnralement des oprations coteuses en termes de performance. La fonction reserve() peut tre utilise pour liminer les r-allocations lorsque la quantit maximum d'lments est connue d'avance.

La complexit (efficacit) des oprations courante sur les vector sont les suivantes :

  • Accs alatoire - constante O(1)
  • Insertion ou le retrait d'lments la fin - constante amortie O(1)
  • Insertion ou le retrait d'lments - linaire O(n)

std::vector rpond aux exigences des concepts Container, AllocatorAwareContainer, SequenceContainer et ReversibleContainer.

Paramtre template

T - Type des lments.
T doit satisfaire aux exigences de CopyAssignable et CopyConstructible. (avant C++11)

Les exigences imposes sur les lments dpendent des oprations raliser sur le conteneur. En rgle gnrale, il est ncessaire que le type des lments rponde aux exigences de MoveConstructible et MoveAssignable, mais de nombreuses fonctions de membres imposent des exigences plus strictes.

(depuis C++11)

[edit]

Allocator - Les allocateurs grent toutes les demandes d'allocation et de dsallocation de la mmoire pour un conteneur gnrique ou personnalis. Le type doit rpondre aux exigences de Allocator. [edit]

Spcialisations

La bibliothque standard fournit une spcialisation de std::vector pour le type bool, qui est optimise pour rduire la taille mmoire utilise par le conteneur.

champ de bits dynamique efficace en espace
(classe gnrique) [edit]

Types des membres

Type du membre Dfinition
value_type T [edit]
allocator_type Allocator [edit]
size_type Type intgral non sign (gnralement size_t)[edit]
difference_type Type intgral sign (gnralement ptrdiff_t) [edit]
reference Allocator::reference (avant C++11)
value_type& (depuis C++11) [edit]
const_reference Allocator::const_reference (avant C++11)
const value_type& (depuis C++11) [edit]
pointer Allocator::pointer (avant C++11)
std::allocator_traits<Allocator>::pointer (depuis C++11) [edit]
const_pointer Allocator::const_pointer (avant C++11)
std::allocator_traits<Allocator>::const_pointer (depuis C++11) [edit]
iterator RandomAccessIterator [edit]
const_iterator Itrateur constant accs alatoire [edit]
reverse_iterator std::reverse_iterator<iterator> [edit]
const_reverse_iterator std::reverse_iterator<const_iterator> [edit]

Fonctions membres

Construit le vector
(fonction membre publique) [edit]
dtruit le vector
(fonction membre publique) [edit]
Attribue les valeurs dans le conteneur
(fonction membre publique) [edit]

Attribue les valeurs dans le conteneur
(fonction membre publique) [edit]

Renvoie l'allocateur associ
(fonction membre publique) [edit]

Accs aux lments
accde l'lment spcifi avec vrification de bornes
(fonction membre publique) [edit]
accde l'lment spcifi
(fonction membre publique) [edit]
accde au premier lment
(fonction membre publique) [edit]
accde au dernier lment
(fonction membre publique) [edit]
(C++11)
accde directement au tableau sous-jacent
(fonction membre publique) [edit]
Itrateurs
retourne un itrateur au dbut
Original:
returns an iterator to the beginning
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
retourne un itrateur la fin
Original:
returns an iterator to the end
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
retourne un itrateur invers au dbut
(fonction membre publique) [edit]
retourne un itrateur invers la fin
(fonction membre publique) [edit]
Capacit
vrifie si le conteneur est vide
Original:
checks whether the container is empty
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
retourne le nombre d'lments
Original:
returns the number of elements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
retourne le plus grand nombre possible d'lments
Original:
returns the maximum possible number of elements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
rserve de l'espace mmoire
(fonction membre publique) [edit]
renvoie le nombre d'lments qui peuvent tre contenus dans l'espace mmoire actuellement allou
(fonction membre publique) [edit]
rduit l'utilisation de la mmoire en librant la mmoire inutilise
Original:
reduces memory usage by freeing unused memory
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
Manipulateurs
efface le contenu
Original:
clears the contents
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
insre des lments
Original:
inserts elements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
(C++11)
construit des lments en mmoire
(fonction membre publique) [edit]
efface des lments
(fonction membre publique) [edit]
ajoute des lments la fin
Original:
adds elements to the end
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
construit des lments en place la fin
(fonction membre publique) [edit]
supprime le dernier lment
Original:
removes the last element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
modifie le nombre d'lments stocks
Original:
changes the number of elements stored
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]
permute les contenus
Original:
swaps the contents
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction membre publique) [edit]

Fonctions libres

compare lexicographiquement les valeurs dans le vector
Original:
lexicographically compares the values in the vector
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction gnrique) [edit]
l'algorithme spcialis std::swap
Original:
specializes the std::swap algorithm
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(fonction gnrique) [edit]

Web Proxy Viewer  |  New URL  |  Original Page