Namespaces
Variants

std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>:: flat_map

From cppreference.net

**Änderungen:** - "since C++23" wurde zu "seit C++23" übersetzt - Alle HTML-Tags, Attribute und Code-Blöcke wurden unverändert beibehalten - C++-spezifische Begriffe (template, class, InputIter, flat_map, std::sorted_unique_t, const, key_compare) wurden nicht übersetzt - Die Formatierung und Struktur der HTML-Elemente bleibt vollständig erhalten (Anmerkung: Der bereitgestellte HTML-Code enthält keinen übersetzbaren Text, da alle Tags leer sind. Die Struktur bleibt unverändert, wie angefordert.)
flat_map ( )
: flat_map ( key_compare ( ) ) { }
(1) (seit C++23)
template < class Allocator >
flat_map ( const flat_map & , const Allocator & alloc ) ;
(2) (seit C++23)
template < class Allocator >
flat_map ( flat_map && , const Allocator & alloc ) ;
(3) (seit C++23)
flat_map ( key_container_type key_cont, mapped_container_type mapped_cont,
const key_compare & comp = key_compare ( ) ) ;
(4) (seit C++23)
template < class Allocator >

flat_map ( const key_container_type & key_cont,
const mapped_container_type & mapped_cont,

const Allocator & alloc ) ;
(5) (seit C++23)
template < class Allocator >

flat_map ( const key_container_type & key_cont,
const mapped_container_type & mapped_cont,

const key_compare & comp, const Allocator & alloc ) ;
(6) (seit C++23)
flat_map ( std:: sorted_unique_t , key_container_type key_cont,

mapped_container_type mapped_cont,

const key_compare & comp = key_compare ( ) ) ;
(7) (seit C++23)
template < class Allocator >

flat_map ( std:: sorted_unique_t , const key_container_type & key_cont,

const mapped_container_type & mapped_cont, const Allocator & alloc ) ;
(8) (seit C++23)
template < class Allocator >

flat_map ( std:: sorted_unique_t , const key_container_type & key_cont,
const mapped_container_type & mapped_cont,

const key_compare & comp, const Allocator & alloc ) ;
(9) (seit C++23)
explicit flat_map ( const key_compare & comp )
: c ( ) , compare ( comp ) { }
(10) (seit C++23)
template < class Allocator >
flat_map ( const key_compare & comp, const Allocator & alloc ) ;
(11) (seit C++23)
template < class Allocator >
explicit flat_map ( const Allocator & alloc ) ;
(12) (seit C++23)
template < class InputIter >

flat_map ( InputIter first, InputIter last,
const key_compare & comp = key_compare ( ) )

: c ( ) , compare ( comp ) ;
(13) (seit C++23)
template < class InputIter, class Allocator >

flat_map ( InputIter first, InputIter last,

const key_compare & comp, const Allocator & alloc ) ;
(14) (seit C++23)
template < class InputIter, class Allocator >
flat_map ( InputIter first, InputIter last, const Allocator & alloc ) ;
(15) (seit C++23)
template < container-compatible-range < value_type > R >

flat_map ( std:: from_range_t , R && rg, const key_compare & comp )

: flat_map ( comp ) ;
(16) (seit C++23)
template < container-compatible-range < value_type > R >

flat_map ( std:: from_range_t fr, R && rg )

: flat_map ( fr, std:: forward < R > ( rg ) , key_compare ( ) ) { }
(17) (seit C++23)
template < container-compatible-range < value_type > R, class Allocator >
flat_map ( std:: from_range_t , R && rg, const Allocator & alloc ) ;
(18) (seit C++23)
template < container-compatible-range < value_type > R, class Allocator >

flat_map ( std:: from_range_t , R && rg, const key_compare & comp,

const Allocator & alloc ) ;
(19) (seit C++23)
template < class InputIter >

flat_map ( std:: sorted_unique_t s, InputIter first, InputIter last,
const key_compare & comp = key_compare ( ) )

: c ( ) , compare ( comp ) ;
(20) (seit C++23)
template < class InputIter, class Allocator >

flat_map ( std:: sorted_unique_t s, InputIter first, InputIter last,

const key_compare & comp, const Allocator & alloc ) ;
(21) (seit C++23)
template < class InputIter, class Allocator >

flat_map ( std:: sorted_unique_t s, InputIter first, InputIter last,

const Allocator & alloc ) ;
(22) (seit C++23)
flat_map ( std:: initializer_list < value_type > init,

const key_compare & comp = key_compare ( ) )

: flat_map ( init. begin ( ) , init. end ( ) , comp ) { }
(23) (seit C++23)
template < class Allocator >

flat_map ( std:: initializer_list < value_type > init, const key_compare & comp,

const Allocator & alloc ) ;
(24) (seit C++23)
template < class Allocator >
flat_map ( std:: initializer_list < value_type > init, const Allocator & alloc ) ;
(25) (seit C++23)
flat_map ( std:: sorted_unique_t s, std:: initializer_list < value_type > init,

const key_compare & comp = key_compare ( ) )

: flat_map ( s, init. begin ( ) , init. end ( ) , comp ) { }
(26) (seit C++23)
template < class Allocator >

flat_map ( std:: sorted_unique_t s, std:: initializer_list < value_type > init,

const key_compare & comp, const Allocator & alloc ) ;
(27) (seit C++23)
template < class Allocator >

flat_map ( std:: sorted_unique_t s, std:: initializer_list < value_type > init,

const Allocator & alloc ) ;
(28) (seit C++23)

Konstruiert einen neuen Container-Adapter aus verschiedenen Datenquellen und optional unter Verwendung des benutzerdefinierten Vergleichsfunktionsobjekts comp und/oder der Zuweisung alloc .

1) Ein Standardkonstruktor. Konstruiert einen leeren Container-Adapter.
2) Ein copy constructor . Konstruiert c mit der Kopie der Inhalte von other. c und compare mit other. compare . Siehe allocator usage note unten.
3) Ein move constructor . Konstruiert den Container-Adapter mit den Inhalten von other unter Verwendung von Move-Semantik. Siehe allocator usage note unten.
4) Initialisiert zunächst c.keys mit std :: move ( key_cont ) , c.values mit std :: move ( mapped_cont ) und compare mit comp . Sortiert anschließend den zugrundeliegenden Bereich [ begin ( ) , end ( ) ) bezüglich value_comp() . Entfernt schließlich doppelte Elemente wie folgt:
auto zv = views:: zip ( c. keys , c. values ) ;
auto it = ranges:: unique ( zv, key_equiv ( compare ) ) . begin ( ) ;
auto dist = distance ( zv. begin ( ) , it ) ;
c. keys . erase ( c. keys . begin ( ) + dist, c. keys . end ( ) ) ;
c. values . erase ( c. values . begin ( ) + dist, c. values . end ( ) ) ;
.
5) Gleich wie (4) , entspricht flat_map ( key_cont, mapped_cont ) ; . Siehe Allokator-Verwendungshinweis unten.
6) Gleich wie (4) , entspricht flat_map ( key_cont, mapped_cont, comp ) ; . Siehe Allokator-Verwendungshinweis unten.
7) Initialisiert c.keys mit std :: move ( key_cont ) , c.values mit std :: move ( mapped_cont ) , und compare mit comp .
8) Gleich wie (7) , äquivalent zu flat_map ( s, key_cont, mapped_cont ) ; . Siehe Allokator-Verwendungshinweis unten.
9) Gleich wie (7) , entspricht flat_map ( s, key_cont, mapped_cont, comp ) ; . Siehe Allokator-Verwendungshinweis unten.
10) Konstruiert einen leeren Container-Adapter.
11,12) Konstruiert einen leeren Container-Adapter. Siehe allocator usage note unten.
13) Konstruiert den Container-Adapter mit den Inhalten des Bereichs [ first , last ) , was äquivalent ist zu insert ( first, last ) ; .
14,15) Gleich wie (13) . Siehe allocator usage note unten.
16) Konstruiert den Container-Adapter mit den Inhalten des Bereichs rg . Zuerst wird (10) als Delegating Constructor verwendet. Dann initialisiert c mit den Inhalten von rg als ob durch insert_range ( std:: forward < R > ( rg ) ) ; .
17) Gleich wie (16) , verwendet als delegating constructor .
18,19) Gleich wie (16) . Siehe Allokator-Verwendungshinweis unten.
20) Konstruiert die zugrundeliegenden Container mit den Inhalten des Bereichs [ first , last ) als ob durch insert ( first, last ) .
21,22) Gleich wie (20) . Siehe allocator usage note unten.
23) Ein initializer-list constructor . Konstruiert den zugrundeliegenden Container mit den Inhalten der Initialisierungsliste init , wobei (13) als delegating constructor verwendet wird.
24,25) Gleich wie (23) . Siehe allocator usage note unten.
26) Ein Initializer-List-Konstruktor . Konstruiert den zugrundeliegenden Container mit den Inhalten der Initialisierungsliste init , wobei (20) als Delegating-Konstruktor verwendet wird.
27,28) Speichern als (26) . Siehe allocator usage note unten.

Hinweis für Überladungen (13-15,20-22) : Wenn [ first , last ) kein gültiger Bereich ist, ist das Verhalten undefiniert.

Note for overloads (4-6,13-19,23-25) : If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted (pending LWG2844 ).

Inhaltsverzeichnis

Hinweis zur Allocator-Verwendung

Die Konstruktoren (2,3,5,6,8,9,11,12,14,15,17,19,21,22,24,25,27,28) entsprechen den entsprechenden Nicht-Allokator-Konstruktoren, mit der Ausnahme, dass die zugrundeliegenden Container c.keys und c.values mit Uses-Allocator-Konstruktion erstellt werden. Diese Überladungen nehmen nur dann an der Überladungsauflösung teil, wenn std:: uses_allocator_v < container_type, Allocator > true ist.

Parameter

key_cont - ein Container, der als Quelle zur Initialisierung des zugrundeliegenden Schlüssel-Containers verwendet wird
mapped_cont - ein Container, der als Quelle zur Initialisierung des zugrundeliegenden Werte-Containers verwendet wird
other - eine weitere flat_map , die als Quelle zur Initialisierung der Elemente der zugrundeliegenden Container verwendet wird
alloc - ein Allokator, der für alle Speicherallokationen der zugrundeliegenden Container verwendet wird
comp - ein Funktionsobjekt, das für alle Schlüsselvergleiche verwendet wird
first, last - das Iteratorpaar, das den Quell- Bereich der zu kopierenden Elemente definiert
init - eine Initialisierungsliste zur Initialisierung der Elemente der zugrundeliegenden Container
rg - ein container-kompatibler Bereich (d.h. ein input_range , dessen Elemente in value_type konvertierbar sind) zur Initialisierung der zugrundeliegenden Container
fr - ein Unterscheidungs-Tag , das anzeigt, dass das enthaltene Element als Bereich konstruiert werden soll
s - ein Unterscheidungs-Tag , das anzeigt, dass die Eingabesequenz bezüglich value_comp() sortiert ist und alle ihre Elemente eindeutig sind
Typanforderungen
-
InputIt muss die Anforderungen von LegacyInputIterator erfüllen.
-
Compare muss die Anforderungen von Compare erfüllen.
-
Allocator muss die Anforderungen von Allocator erfüllen.

Komplexität

1) Konstante.
2) Linear in der Größe von other .
3) Gleich wie der entsprechende Move-Konstruktor des umschlossenen Containers, d.h. konstant oder linear in der Größe von cont .
4-6) Linear in N if cont is sorted with respect to value_comp() , otherwise 𝓞(N·log(N)) , where N is the value of key_cont. size ( ) before this call.
7-9) Identisch zum entsprechenden Move-Konstruktor des umschlossenen Containers, d.h. konstant oder linear in der Größe von cont .
10-12) Konstante.
13-15) Linear in N if the input range [ first , last ) is sorted with respect to value_comp() , otherwise 𝓞(N·log(N)) , where N is the value of key_cont. size ( ) before this call.
16-19) Linear in N if the input range rg is sorted with respect to value_comp() , otherwise 𝓞(N·log(N)) , where N is the value of key_cont. size ( ) before this call.
20-22) Linear in der Größe von [ first , last ) .
23-25) Linear in N if the elements of init are sorted with respect to value_comp() , otherwise 𝓞(N·log(N)) , where N is the value of key_cont. size ( ) before this call.
26-28) Linear in der Größe von init .

Exceptions

Aufrufe von Allocator::allocate können eine Ausnahme auslösen.

Hinweise

Nach Container-Move-Konstruktion (Überladung ( 3 ) ) bleiben Referenzen, Zeiger und Iteratoren (außer dem End-Iterator) zu other gültig, verweisen jedoch auf Elemente, die sich nun in * this befinden. Der aktuelle Standard gibt diese Garantie durch die pauschale Aussage in [container.reqmts]/67 , und eine direktere Garantie wird via LWG issue 2321 in Betracht gezogen.

Beispiel

Siehe auch

weist Werte dem Container-Adapter zu
(öffentliche Elementfunktion)