Namensräume
Varianten

std::vector

Aus cppreference.com
< cpp‎ | container
 
 
 
std::vector
Member-Funktionen
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
Elementzugriff zerstört
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)
Iteratoren
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)
Kapazität
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)
Modifiers
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
 
definiert in Header <vector>
template<

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

>class vector;

std::vector ist ein sequentieller Container, der Arrays dynamischer Größe kapselt.

Die Elemente werden zusammenhängend gespeichert, was bedeutet, dass auf die Elemente nicht nur durch Iteratoren zugegriffen werden kann, sondern auch mit Offsets auf reguläre Zeiger auf Elemente. Dies bedeutet, dass ein Zeiger auf ein Element eines Vektors an eine beliebige Funktion übergeben werden kann, die einen Zeiger auf ein Element eines Array erwartet.

Der Speicherplatz des Vektors wird automatisch angepasst, er wird je nach Bedarf erweitert und verkleinert. Vektoren belegen in der Regel mehr Platz als statische Arrays, weil mehr Speicher zugewiesen wird um zukünftiges Wachstum zu behandeln. Auf diese Weise muss der Speicher eines Vektor nicht jedes Mal neu alloziert werden, wenn ein Element hinzugefügt wird, sondern nur, wenn der zusätzliche Speicher erschöpft ist. Die Größe des allozierten Speichers kann mit der Methode capacity() abgefragt werden. Zusätzlicher Speicher kann dem System über einen Aufruf von shrink_to_fit() zurückgegeben werden.

Um kostspielige Reallokationen zu vermeiden, kann der Speicher mit reserve() vorallokiert werden, wenn die Anzahl von Elementen im voraus bekannt ist.

Die Komplexität (Wirkungsgrad) der gemeinsamen Operationen auf Vektoren ist wie folgt:

  • Random Access - konstant O(1)
  • Das Einsetzen oder Entfernen von Elementen am Ende - durchschnittlich konstant O(1)
  • Einsetzen oder Entfernen von Elementen - linear zum Abstand des Vektorendes O(n)

std::vector erfüllt die Anforderungen der Container, AllocatorAwareContainer, SequenceContainer und ReversibleContainer .

Inhaltsverzeichnis

[Bearbeiten]Spezialisierungen

Die Standard-Bibliothek bietet eine Spezialisierung von std::vector für den Datentyp bool, die in Bezug auf Speicherplatz optimiert ist.

platzsparendes dynamisches Bitset
(Klassen-Template)[edit]

[Bearbeiten]Mitglied Typen

Mitglied Typ
Original:
Member type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
value_typeT[edit]
allocator_typeAllocator[edit]
size_type vorzeichenloser ganzzahliger Typ (in der Regel size_t)[edit]
difference_type vorzeichenbehafteter Typ (usually ptrdiff_t) [edit]
referenceAllocator::reference(bis C + +11)
value_type&(seit C++11)[edit]
const_referenceAllocator::const_reference(bis C + +11)
const value_type&(seit C++11)[edit]
pointerAllocator::pointer(bis C + +11)
std::allocator_traits<Allocator>::pointer(seit C++11)[edit]
const_pointerAllocator::const_pointer(bis C + +11)
std::allocator_traits<Allocator>::const_pointer(seit C++11)[edit]
iteratorRandomAccessIterator[edit]
const_iterator
Constant random access iterator
Original:
Constant random access iterator
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[edit]
reverse_iteratorstd::reverse_iterator<iterator>[edit]
const_reverse_iteratorstd::reverse_iterator<const_iterator>[edit]

[Bearbeiten]Member-Funktionen

konstruiert die vector
(öffentliche Elementfunktion)[edit]
zerstört die vector
(öffentliche Elementfunktion)[edit]
weist Werte auf den Behälter
Original:
assigns values to the container
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
weist Werte auf den Behälter
Original:
assigns values to the container
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
liefert den zugehörigen Allocator
(öffentliche Elementfunktion)[edit]
Elementzugriff
Zugriff auf angegebene Element mit Überprüfung von Grenzen
Original:
access specified element with bounds checking
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
Zugriff auf angegebene Element
Original:
access specified element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
Zugriff auf das erste Element
Original:
access the first element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
Zugriff auf das letzte Element
(öffentliche Elementfunktion)[edit]
(C++11)
Direkter Zugang zu dem zugrundeliegenden Array
(öffentliche Elementfunktion)[edit]
Iteratoren
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
liefert einen Iterator an den Anfang
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.

(öffentliche Elementfunktion)[edit]
liefert einen Iterator bis zum Ende
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.

(öffentliche Elementfunktion)[edit]
gibt einen umgekehrten Iterator an den Anfang
Original:
returns a reverse 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.

(öffentliche Elementfunktion)[edit]
gibt einen umgekehrten Iterator bis zum Ende
Original:
returns a reverse 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.

(öffentliche Elementfunktion)[edit]
Kapazität
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
prüft, ob der Container leer ist
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.

(öffentliche Elementfunktion)[edit]
liefert die Anzahl der Elemente
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.

(öffentliche Elementfunktion)[edit]
gibt die maximal mögliche Anzahl von Elementen
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.

(öffentliche Elementfunktion)[edit]
reserviert Speicher
(öffentliche Elementfunktion)[edit]
gibt die Anzahl der Elemente, die in derzeit zugewiesenen Speicher gehalten werden kann
Original:
returns the number of elements that can be held in currently allocated storage
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
verringert den Speicherbedarf durch Freigeben ungenutzten Speichers
(öffentliche Elementfunktion)[edit]
Modifiers
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
löscht den Inhalt
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.

(öffentliche Elementfunktion)[edit]
Elemente einfügen
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.

(öffentliche Elementfunktion)[edit]
(C++11)
constructs element in-place
(öffentliche Elementfunktion)[edit]
löscht Elemente
Original:
erases elements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
fügt Elemente am Ende
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.

(öffentliche Elementfunktion)[edit]
baut Elemente-Platz am Ende
Original:
constructs elements in-place at the end
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(öffentliche Elementfunktion)[edit]
entfernt das letzte Element
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.

(öffentliche Elementfunktion)[edit]
ändert die Anzahl der gespeicherten Elemente
(öffentliche Elementfunktion)[edit]
tauscht die Inhalte
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.

(öffentliche Elementfunktion)[edit]

[Bearbeiten]Non-Member-Funktionen

lexikographischer Vergleich der Werte in vector
(Funktions-Template)[edit]
spezialisiert die std::swap Algorithmus
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.

(Funktions-Template)[edit]
close