Espaços nominais
Variantes
Acções

<div class="t-tr-text">C + +: conceitos<div class="t-tr-dropdown"><div><div><div class="t-tr-dropdown-arrow-border"></div><div class="t-tr-dropdown-arrow"></div><div class="t-tr-dropdown-h">Original:</div><div class="t-tr-dropdown-orig">C++ concepts:</div><div class="t-tr-dropdown-notes">The text has been machine-translated via [http://translate.google.com Google Translate].<br/> You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.</div></div></div></div></div> Container

Da cppreference.com
< cpp‎ | concept

 
 
C + + conceitos
Basic
Original:
Basic
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Biblioteca-Wide
Original:
Library-Wide
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Container
Original:
Container
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Elementos de contêineres
Original:
Container Elements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Iterator
Original:
Iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Números aleatórios
Original:
Random Numbers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Simultaneidade
Original:
Concurrency
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
Outro
Original:
Other
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
A Container é um objeto usado para armazenar outros objetos e cuidar da gestão da memória usada pelos objetos que ele contém.
Original:
A Container is an object used to store other objects and taking care of the management of the memory used by the objects it contains.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Índice

[editar]Requisitos

  • C tipo Container
    Original:
    C Container type
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • T tipo de elemento
    Original:
    T Element type
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • a, b Objetos de C tipo
    Original:
    a, b Objects of type C
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[editar]Tipos

nametypenotes
value_typeTDestructible
referencelvalue of T
const_referenceconst lvalue of T
iteratoriterator pointing to TForwardIterator
convertible to const_iterator
const_iteratorconst iterator pointing to TForwardIterator
difference_typesigned integer must be the same as iterator_traits::difference_type for iterator and const_iterator
size_typeunsigned integerlarge enough to represent all positive values of difference_type

[editar]Métodos e operadores

expressionreturn typesemanticsconditionscomplexity
C();CCreates an empty container Post: u.empty() == trueConstant
C(a)CCreate a copy of aPre: T must be CopyInsertable
Post: a == X(a)
Linear
a = bC&All elements of a are destroyed or move assigned to elements of bPost: a == bLinear
(&a)->~C()voidDestroy all elements and free all memoryLinear
a.begin()(const_)iteratorIterator to the first elementConstant
a.end()(const_)iteratorIterator to one passed the last elementConstant
a.cbegin()(desde C++11)const_iteratorconst_cast<const C&>(a).begin()Constant
a.cend()(desde C++11)const_iteratorconst_cast<const C&>(a).end()Constant
a == b convertible to bool Makes C EqualityComparablePre: T must be EqualityComparable Linear
a != b convertible to bool !(a==b) Linear
a.swap(b) void exchanges the values of a and b Constant[1][2]
swap(a,b) void a.swap(b) Constant[1]
a.size() size_type distance(a.begin(),a.end()) Constant[2]
a.max_size() size_type b.size() where b is the largest possible container Constant[2]
a.empty() convertible to bool a.begin()== a.end() Constant
notes
  1. 1,01,1(desde C++11) Linear for std::array
  2. 2,02,12,2(até C++11) Not strictly constant

[editar]Dados corridas de contêineres

Implementações não são obrigados a fornecer qualquer garantia de reentrada para modificações seqüência - não é seguro para push_back e ler begin simultaneamente. No entanto, é necessário evitar as corridas de dados, quando o conteúdo do objecto contido em diferentes elementos da mesma sequência são modificadas ao mesmo tempo (excepto para vector<bool>). Em outras palavras, para um vector<int> com tamanho superior a 1, e x[1] = 5*x.begin() = 10 não vai resultar em uma corrida de dados.
Original:
Implementations are not required to provide any reentrancy guarantee for sequence modifications - it is not safe to push_back and read begin concurrently. However, it is required to avoid data races when the contents of the contained object in different elements of the same sequence are modified concurrently (except for vector<bool>). In other words, for a vector<int> with size greater than 1, x[1] = 5 and *x.begin() = 10 will not result in a data race.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Estas funções também devem ser considerados const: begin, end, rbegin, rend, front, back, data, find, lower_bound, upper_bound, equal_range, at, e, exceto em AssociativeContainer e UnorderedAssociativeContainer, operator[]. Chamar qualquer uma dessas funções simultaneamente não vai resultar em uma corrida de dados.
Original:
These functions must also be considered const: begin, end, rbegin, rend, front, back, data, find, lower_bound, upper_bound, equal_range, at, and, except in AssociativeContainer and UnorderedAssociativeContainer, operator[]. Calling any of these functions concurrently will not result in a data race.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar]Outros conceitos

C
T
close