Difference between revisions of "cpp/container"
(more exciting redlinks) |
(+) |
||
Line 203: | Line 203: | ||
! colspan="4" | Associative containers | ! colspan="4" | Associative containers | ||
! colspan="4" | Unordered associative containers | ! colspan="4" | Unordered associative containers | ||
− | ! colspan=" | + | ! colspan="7" | Container adaptors |
|- | |- | ||
! colspan="2" | Header | ! colspan="2" | Header | ||
Line 217: | Line 217: | ||
! {{tt|{{header|stack}}}} | ! {{tt|{{header|stack}}}} | ||
! colspan="2" | {{tt|{{header|queue}}}} | ! colspan="2" | {{tt|{{header|queue}}}} | ||
+ | ! colspan="2" | {{tt|{{header|flat_set}}}} | ||
+ | ! colspan="2" | {{tt|{{header|flat_map}}}} | ||
|- | |- | ||
! colspan="2" | Container | ! colspan="2" | Container | ||
Line 235: | Line 237: | ||
! {{cpp/container/table cell ho | /queue }} | ! {{cpp/container/table cell ho | /queue }} | ||
! {{cpp/container/table cell ho | /priority_queue }} | ! {{cpp/container/table cell ho | /priority_queue }} | ||
+ | ! {{cpp/container/table cell ho | /flat_set }} | ||
+ | ! {{cpp/container/table cell ho | /flat_multiset }} | ||
+ | ! {{cpp/container/table cell ho | /flat_map }} | ||
+ | ! {{cpp/container/table cell ho | /flat_multimap }} | ||
|- | |- | ||
! rowspan="4" | | ! rowspan="4" | | ||
Line 254: | Line 260: | ||
| {{cpp/container/table cell o | /queue/queue }} | | {{cpp/container/table cell o | /queue/queue }} | ||
| {{cpp/container/table cell o | /priority_queue/priority_queue }} | | {{cpp/container/table cell o | /priority_queue/priority_queue }} | ||
+ | | {{cpp/container/table cell o | /flat_set/flat_set }} | ||
+ | | {{cpp/container/table cell o | /flat_multiset/flat_multiset }} | ||
+ | | {{cpp/container/table cell o | /flat_map/flat_map }} | ||
+ | | {{cpp/container/table cell o | /flat_multimap/flat_multimap }} | ||
|- | |- | ||
<!-- ---> | <!-- ---> | ||
Line 273: | Line 283: | ||
| {{cpp/container/table cell o | /queue/~queue }} | | {{cpp/container/table cell o | /queue/~queue }} | ||
| {{cpp/container/table cell o | /priority_queue/~priority_queue }} | | {{cpp/container/table cell o | /priority_queue/~priority_queue }} | ||
+ | | {{cpp/container/table cell o | /flat_set/~flat_set }} | ||
+ | | {{cpp/container/table cell o | /flat_multiset/~flat_multiset }} | ||
+ | | {{cpp/container/table cell o | /flat_map/~flat_map }} | ||
+ | | {{cpp/container/table cell o | /flat_multimap/~flat_multimap }} | ||
|- | |- | ||
<!-- --> | <!-- --> | ||
Line 292: | Line 306: | ||
| {{cpp/container/table cell o | /queue/operator{{=}} }} | | {{cpp/container/table cell o | /queue/operator{{=}} }} | ||
| {{cpp/container/table cell o | /priority_queue/operator{{=}} }} | | {{cpp/container/table cell o | /priority_queue/operator{{=}} }} | ||
+ | | {{cpp/container/table cell o | /flat_set/operator{{=}} }} | ||
+ | | {{cpp/container/table cell o | /flat_multiset/operator{{=}} }} | ||
+ | | {{cpp/container/table cell o | /flat_map/operator{{=}} }} | ||
+ | | {{cpp/container/table cell o | /flat_multimap/operator{{=}} }} | ||
|- | |- | ||
<!-- --> | <!-- --> | ||
Line 300: | Line 318: | ||
| {{cpp/container/table cell n | /forward_list/assign }} | | {{cpp/container/table cell n | /forward_list/assign }} | ||
| {{cpp/container/table cell o | /list/assign }} | | {{cpp/container/table cell o | /list/assign }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 330: | Line 352: | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
+ | | {{cpp/container/table cell nn | /flat_set/begin |begin|cbegin }} | ||
+ | | {{cpp/container/table cell nn | /flat_multiset/begin |begin|cbegin }} | ||
+ | | {{cpp/container/table cell nn | /flat_map/begin |begin|cbegin }} | ||
+ | | {{cpp/container/table cell nn | /flat_multimap/begin |begin|cbegin }} | ||
|- | |- | ||
<!-- --> | <!-- --> | ||
Line 349: | Line 375: | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
+ | | {{cpp/container/table cell nn | /flat_set/end |end|cend }} | ||
+ | | {{cpp/container/table cell nn | /flat_multiset/end |end|cend }} | ||
+ | | {{cpp/container/table cell nn | /flat_map/end |end|cend }} | ||
+ | | {{cpp/container/table cell nn | /flat_multimap/end |end|cend }} | ||
|- | |- | ||
<!-- --> | <!-- --> | ||
Line 368: | Line 398: | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
+ | | {{cpp/container/table cell nn | /flat_set/rbegin |rbegin|crbegin}} | ||
+ | | {{cpp/container/table cell nn | /flat_multiset/rbegin |rbegin|crbegin}} | ||
+ | | {{cpp/container/table cell nn | /flat_map/rbegin |rbegin|crbegin}} | ||
+ | | {{cpp/container/table cell nn | /flat_multimap/rbegin |rbegin|crbegin}} | ||
|- | |- | ||
<!-- --> | <!-- --> | ||
Line 387: | Line 421: | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
+ | | {{cpp/container/table cell nn | /flat_set/rend |rend|crend}} | ||
+ | | {{cpp/container/table cell nn | /flat_multiset/rend |rend|crend}} | ||
+ | | {{cpp/container/table cell nn | /flat_map/rend |rend|crend}} | ||
+ | | {{cpp/container/table cell nn | /flat_multimap/rend |rend|crend}} | ||
|- | |- | ||
! rowspan="5" | Element <br> access | ! rowspan="5" | Element <br> access | ||
Line 402: | Line 440: | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{cpp/container/table cell n | /unordered_map/at }} | | {{cpp/container/table cell n | /unordered_map/at }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 421: | Line 463: | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{cpp/container/table cell n | /unordered_map/operator_at |operator[]}} | | {{cpp/container/table cell n | /unordered_map/operator_at |operator[]}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 430: | Line 476: | ||
| {{cpp/container/table cell n | /array/data }} | | {{cpp/container/table cell n | /array/data }} | ||
| {{cpp/container/table cell n | /vector/data }} | | {{cpp/container/table cell n | /vector/data }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 463: | Line 513: | ||
| {{cpp/container/table cell o | /queue/front }} | | {{cpp/container/table cell o | /queue/front }} | ||
| {{cpp/container/table cell o | /priority_queue/top | top }} | | {{cpp/container/table cell o | /priority_queue/top | top }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
|- | |- | ||
<!-- --> | <!-- --> | ||
Line 481: | Line 535: | ||
| {{cpp/container/table cell o | /stack/top | top}} | | {{cpp/container/table cell o | /stack/top | top}} | ||
| {{cpp/container/table cell o | /queue/back }} | | {{cpp/container/table cell o | /queue/back }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
|- | |- | ||
Line 501: | Line 559: | ||
| {{cpp/container/table cell o | /queue/empty }} | | {{cpp/container/table cell o | /queue/empty }} | ||
| {{cpp/container/table cell o | /priority_queue/empty }} | | {{cpp/container/table cell o | /priority_queue/empty }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
|- | |- | ||
<!-- --> | <!-- --> | ||
Line 520: | Line 582: | ||
| {{cpp/container/table cell o | /queue/size }} | | {{cpp/container/table cell o | /queue/size }} | ||
| {{cpp/container/table cell o | /priority_queue/size }} | | {{cpp/container/table cell o | /priority_queue/size }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
|- | |- | ||
<!-- --> | <!-- --> | ||
Line 536: | Line 602: | ||
| {{cpp/container/table cell n | /unordered_map/max_size }} | | {{cpp/container/table cell n | /unordered_map/max_size }} | ||
| {{cpp/container/table cell n | /unordered_multimap/max_size }} | | {{cpp/container/table cell n | /unordered_multimap/max_size }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 547: | Line 617: | ||
| {{cpp/container/table cell n | /forward_list/resize }} | | {{cpp/container/table cell n | /forward_list/resize }} | ||
| {{cpp/container/table cell o | /list/resize }} | | {{cpp/container/table cell o | /list/resize }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 574: | Line 648: | ||
| {{cpp/container/table cell n | /unordered_map/bucket_count }} | | {{cpp/container/table cell n | /unordered_map/bucket_count }} | ||
| {{cpp/container/table cell n | /unordered_multimap/bucket_count }} | | {{cpp/container/table cell n | /unordered_multimap/bucket_count }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 593: | Line 671: | ||
| {{cpp/container/table cell n | /unordered_map/reserve }} | | {{cpp/container/table cell n | /unordered_map/reserve }} | ||
| {{cpp/container/table cell n | /unordered_multimap/reserve }} | | {{cpp/container/table cell n | /unordered_multimap/reserve }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 602: | Line 684: | ||
| {{cpp/container/table cell n | /vector/shrink_to_fit}} | | {{cpp/container/table cell n | /vector/shrink_to_fit}} | ||
| {{cpp/container/table cell n | /deque/shrink_to_fit}} | | {{cpp/container/table cell n | /deque/shrink_to_fit}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 632: | Line 718: | ||
| {{cpp/container/table cell n | /unordered_multimap/clear }} | | {{cpp/container/table cell n | /unordered_multimap/clear }} | ||
| {{n/a|}} | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 650: | Line 740: | ||
| {{cpp/container/table cell n | /unordered_map/insert }} | | {{cpp/container/table cell n | /unordered_map/insert }} | ||
| {{cpp/container/table cell n | /unordered_multimap/insert }} | | {{cpp/container/table cell n | /unordered_multimap/insert }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 668: | Line 762: | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{cpp/container/table cell 17 | /unordered_map/insert_or_assign }} | | {{cpp/container/table cell 17 | /unordered_map/insert_or_assign }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 688: | Line 786: | ||
| {{cpp/container/table cell n | /unordered_map/emplace }} | | {{cpp/container/table cell n | /unordered_map/emplace }} | ||
| {{cpp/container/table cell n | /unordered_multimap/emplace }} | | {{cpp/container/table cell n | /unordered_multimap/emplace }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 707: | Line 809: | ||
| {{cpp/container/table cell n | /unordered_map/emplace_hint }} | | {{cpp/container/table cell n | /unordered_map/emplace_hint }} | ||
| {{cpp/container/table cell n | /unordered_multimap/emplace_hint }} | | {{cpp/container/table cell n | /unordered_multimap/emplace_hint }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 725: | Line 831: | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{cpp/container/table cell 17 | /unordered_map/try_emplace }} | | {{cpp/container/table cell 17 | /unordered_map/try_emplace }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 746: | Line 856: | ||
| {{cpp/container/table cell n | /unordered_multimap/erase }} | | {{cpp/container/table cell n | /unordered_multimap/erase }} | ||
| {{n/a|}} | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 756: | Line 870: | ||
| {{cpp/container/table cell n | /forward_list/push_front }} | | {{cpp/container/table cell n | /forward_list/push_front }} | ||
| {{cpp/container/table cell o | /list/push_front }} | | {{cpp/container/table cell o | /list/push_front }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 784: | Line 902: | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 805: | Line 927: | ||
| {{cpp/container/table cell o | /queue/pop }} | | {{cpp/container/table cell o | /queue/pop }} | ||
| {{cpp/container/table cell o | /priority_queue/pop}} | | {{cpp/container/table cell o | /priority_queue/pop}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
|- | |- | ||
<!-- --> | <!-- --> | ||
Line 824: | Line 950: | ||
| {{cpp/container/table cell o | /queue/push}} | | {{cpp/container/table cell o | /queue/push}} | ||
| {{cpp/container/table cell o | /priority_queue/push}} | | {{cpp/container/table cell o | /priority_queue/push}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
|- | |- | ||
<!-- --> | <!-- --> | ||
Line 843: | Line 973: | ||
| {{cpp/container/table cell n | /queue/emplace}} | | {{cpp/container/table cell n | /queue/emplace}} | ||
| {{cpp/container/table cell n | /priority_queue/emplace}} | | {{cpp/container/table cell n | /priority_queue/emplace}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
|- | |- | ||
<!-- --> | <!-- --> | ||
Line 860: | Line 994: | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{cpp/container/table cell o | /stack/pop}} | | {{cpp/container/table cell o | /stack/pop}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 881: | Line 1,019: | ||
| {{cpp/container/table cell n | /queue/swap }} | | {{cpp/container/table cell n | /queue/swap }} | ||
| {{cpp/container/table cell n | /priority_queue/swap }} | | {{cpp/container/table cell n | /priority_queue/swap }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
|- | |- | ||
<!-- --> | <!-- --> | ||
Line 897: | Line 1,039: | ||
| {{cpp/container/table cell 17 | /unordered_map/merge }} | | {{cpp/container/table cell 17 | /unordered_map/merge }} | ||
| {{cpp/container/table cell 17 | /unordered_multimap/merge }} | | {{cpp/container/table cell 17 | /unordered_multimap/merge }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 916: | Line 1,062: | ||
| {{cpp/container/table cell 17 | /unordered_map/extract }} | | {{cpp/container/table cell 17 | /unordered_map/extract }} | ||
| {{cpp/container/table cell 17 | /unordered_multimap/extract }} | | {{cpp/container/table cell 17 | /unordered_multimap/extract }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 927: | Line 1,077: | ||
| {{cpp/container/table cell n | /forward_list/splice_after | splice_after }} | | {{cpp/container/table cell n | /forward_list/splice_after | splice_after }} | ||
| {{cpp/container/table cell o | /list/splice }} | | {{cpp/container/table cell o | /list/splice }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 946: | Line 1,100: | ||
| {{cpp/container/table cell n | /forward_list/remove }} | | {{cpp/container/table cell n | /forward_list/remove }} | ||
| {{cpp/container/table cell o | /list/remove }} | | {{cpp/container/table cell o | /list/remove }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 965: | Line 1,123: | ||
| {{cpp/container/table cell n | /forward_list/remove | remove_if }} | | {{cpp/container/table cell n | /forward_list/remove | remove_if }} | ||
| {{cpp/container/table cell o | /list/remove | remove_if }} | | {{cpp/container/table cell o | /list/remove | remove_if }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 984: | Line 1,146: | ||
| {{cpp/container/table cell n | /forward_list/reverse }} | | {{cpp/container/table cell n | /forward_list/reverse }} | ||
| {{cpp/container/table cell o | /list/reverse }} | | {{cpp/container/table cell o | /list/reverse }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 1,003: | Line 1,169: | ||
| {{cpp/container/table cell n | /forward_list/unique }} | | {{cpp/container/table cell n | /forward_list/unique }} | ||
| {{cpp/container/table cell o | /list/unique }} | | {{cpp/container/table cell o | /list/unique }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 1,022: | Line 1,192: | ||
| {{cpp/container/table cell n | /forward_list/sort }} | | {{cpp/container/table cell n | /forward_list/sort }} | ||
| {{cpp/container/table cell o | /list/sort }} | | {{cpp/container/table cell o | /list/sort }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 1,049: | Line 1,223: | ||
| {{cpp/container/table cell n | /unordered_map/count }} | | {{cpp/container/table cell n | /unordered_map/count }} | ||
| {{cpp/container/table cell n | /unordered_multimap/count }} | | {{cpp/container/table cell n | /unordered_multimap/count }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 1,068: | Line 1,246: | ||
| {{cpp/container/table cell n | /unordered_map/find }} | | {{cpp/container/table cell n | /unordered_map/find }} | ||
| {{cpp/container/table cell n | /unordered_multimap/find }} | | {{cpp/container/table cell n | /unordered_multimap/find }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 1,087: | Line 1,269: | ||
| {{cpp/container/table cell 20 | /unordered_map/contains }} | | {{cpp/container/table cell 20 | /unordered_map/contains }} | ||
| {{cpp/container/table cell 20 | /unordered_multimap/contains }} | | {{cpp/container/table cell 20 | /unordered_multimap/contains }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 1,102: | Line 1,288: | ||
| {{cpp/container/table cell o | /map/lower_bound }} | | {{cpp/container/table cell o | /map/lower_bound }} | ||
| {{cpp/container/table cell o | /multimap/lower_bound }} | | {{cpp/container/table cell o | /multimap/lower_bound }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 1,121: | Line 1,311: | ||
| {{cpp/container/table cell o | /map/upper_bound }} | | {{cpp/container/table cell o | /map/upper_bound }} | ||
| {{cpp/container/table cell o | /multimap/upper_bound }} | | {{cpp/container/table cell o | /multimap/upper_bound }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 1,144: | Line 1,338: | ||
| {{cpp/container/table cell n | /unordered_map/equal_range }} | | {{cpp/container/table cell n | /unordered_map/equal_range }} | ||
| {{cpp/container/table cell n | /unordered_multimap/equal_range }} | | {{cpp/container/table cell n | /unordered_multimap/equal_range }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 1,159: | Line 1,357: | ||
| {{cpp/container/table cell o | /map/key_comp }} | | {{cpp/container/table cell o | /map/key_comp }} | ||
| {{cpp/container/table cell o | /multimap/key_comp }} | | {{cpp/container/table cell o | /multimap/key_comp }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 1,178: | Line 1,380: | ||
| {{cpp/container/table cell o | /map/value_comp }} | | {{cpp/container/table cell o | /map/value_comp }} | ||
| {{cpp/container/table cell o | /multimap/value_comp }} | | {{cpp/container/table cell o | /multimap/value_comp }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 1,201: | Line 1,407: | ||
| {{cpp/container/table cell n | /unordered_map/hash_function }} | | {{cpp/container/table cell n | /unordered_map/hash_function }} | ||
| {{cpp/container/table cell n | /unordered_multimap/hash_function }} | | {{cpp/container/table cell n | /unordered_multimap/hash_function }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 1,220: | Line 1,430: | ||
| {{cpp/container/table cell n | /unordered_map/key_eq }} | | {{cpp/container/table cell n | /unordered_map/key_eq }} | ||
| {{cpp/container/table cell n | /unordered_multimap/key_eq }} | | {{cpp/container/table cell n | /unordered_multimap/key_eq }} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 1,240: | Line 1,454: | ||
| {{cpp/container/table cell n | /unordered_multimap/get_allocator }} | | {{cpp/container/table cell n | /unordered_multimap/get_allocator }} | ||
| {{n/a|}} | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
+ | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
| {{n/a|}} | | {{n/a|}} | ||
Line 1,260: | Line 1,478: | ||
! {{cpp/container/table cell ho | /queue }} | ! {{cpp/container/table cell ho | /queue }} | ||
! {{cpp/container/table cell ho | /priority_queue }} | ! {{cpp/container/table cell ho | /priority_queue }} | ||
+ | ! {{cpp/container/table cell ho | /flat_set }} | ||
+ | ! {{cpp/container/table cell ho | /flat_multiset }} | ||
+ | ! {{cpp/container/table cell ho | /flat_map }} | ||
+ | ! {{cpp/container/table cell ho | /flat_multimap }} | ||
|- | |- | ||
| colspan="2" | | | colspan="2" | | ||
Line 1,265: | Line 1,487: | ||
! colspan="4" | Associative containers | ! colspan="4" | Associative containers | ||
! colspan="4" | Unordered associative containers | ! colspan="4" | Unordered associative containers | ||
− | ! colspan=" | + | ! colspan="7" | Container adaptors |
|} | |} | ||
</div> | </div> |
Revision as of 06:47, 22 September 2022
The Containers library is a generic collection of class templates and algorithms that allow programmers to easily implement common data structures like queues, lists and stacks. There are two(until C++11)three(since C++11) classes of containers:
- sequence containers,
- associative containers, and
|
(since C++11) |
each of which is designed to support a different set of operations.
The container manages the storage space that is allocated for its elements and provides member functions to access them, either directly or through iterators (objects with properties similar to pointers).
Most containers have at least several member functions in common, and share functionalities. Which container is the best for the particular application depends not only on the offered functionality, but also on its efficiency for different workloads.
Contents |
Sequence containers
Sequence containers implement data structures which can be accessed sequentially.
(C++11) |
fixed-sized inplace contiguous array (class template) |
dynamic contiguous array (class template) | |
double-ended queue (class template) | |
(C++11) |
singly-linked list (class template) |
doubly-linked list (class template) |
Associative containers
Associative containers implement sorted data structures that can be quickly searched (O(log n) complexity).
collection of unique keys, sorted by keys (class template) | |
collection of key-value pairs, sorted by keys, keys are unique (class template) | |
collection of keys, sorted by keys (class template) | |
collection of key-value pairs, sorted by keys (class template) |
Unordered associative containers (since C++11)
Unordered associative containers implement unsorted (hashed) data structures that can be quickly searched (O(1) amortized, O(n) worst-case complexity).
(C++11) |
collection of unique keys, hashed by keys (class template) |
(C++11) |
collection of key-value pairs, hashed by keys, keys are unique (class template) |
(C++11) |
collection of keys, hashed by keys (class template) |
(C++11) |
collection of key-value pairs, hashed by keys (class template) |
Container adaptors
Container adaptors provide a different interface for sequential containers.
adapts a container to provide stack (LIFO data structure) (class template) | |
adapts a container to provide queue (FIFO data structure) (class template) | |
adapts a container to provide priority queue (class template) | |
(C++23) |
adapts a container to provide a collection of unique keys, sorted by keys (class template) |
(C++23) |
adapts two containers to provide a collection of key-value pairs, sorted by unique keys (class template) |
(C++23) |
adapts a container to provide a collection of keys, sorted by keys (class template) |
(C++23) |
adapts two containers to provide a collection of key-value pairs, sorted by keys (class template) |
Views
span
(since C++20) and mdspan
(since C++23) are non-owning views over a contiguous sequence of objects, the storage of which is owned by some other object.
(C++20) |
a non-owning view over a contiguous sequence of objects (class template) |
(C++23) |
a multi-dimensional non-owning array view (class template) |
Iterator invalidation
Read-only methods never invalidate iterators or references. Methods which modify the contents of a container may invalidate iterators and/or references, as summarized in this table.
Category | Container | After insertion, are... | After erasure, are... | Conditionally | ||
---|---|---|---|---|---|---|
iterators valid? | references valid? | iterators valid? | references valid? | |||
Sequence containers | array | N/A | N/A | |||
vector | No | N/A | Insertion changed capacity | |||
Yes | Yes | Before modified element(s) (for insertion only if capacity didn't change) | ||||
No | No | At or after modified element(s) | ||||
deque | No | Yes | Yes, except erased element(s) | Modified first or last element | ||
No | No | Modified middle only | ||||
list | Yes | Yes, except erased element(s) | ||||
forward_list | Yes | Yes, except erased element(s) | ||||
Associative containers | set multiset map multimap |
Yes | Yes, except erased element(s) | |||
Unordered associative containers | unordered_set unordered_multiset unordered_map unordered_multimap |
No | Yes | N/A | Insertion caused rehash | |
Yes | Yes, except erased element(s) | No rehash |
Here, insertion refers to any method which adds one or more elements to the container and erasure refers to any method which removes one or more elements from the container.
- Examples of insertion methods are std::set::insert, std::map::emplace, std::vector::push_back, and std::deque::push_front.
|
(since C++11) |
- Examples of erasure methods are std::set::erase, std::vector::pop_back, std::deque::pop_front, and std::map::clear.
-
clear
invalidates all iterators and references. Because it erases all elements, this technically complies with the rules above.
-
Unless otherwise specified (either explicitly or by defining a function in terms of other functions), passing a container as an argument to a library function never invalidate iterators to, or change the values of, objects within that container.
The past-the-end iterator deserves particular mention. In general this iterator is invalidated as though it were a normal iterator to a non-erased element. So std::set::end is never invalidated, std::unordered_set::end is invalidated only on rehash(since C++11), std::vector::end is always invalidated (since it is always after the modified elements), and so on.
There is one exception: an erasure which deletes the last element of a std::deque does invalidate the past-the-end iterator, even though it is not an erased element of the container (or an element at all). Combined with the general rules for std::deque iterators, the net result is that the only modifying operation which does not invalidate std::deque::end is an erasure which deletes the first element, but not the last.
Thread safety
|
(since C++11) |
Member function table
This section is incomplete Reason: This table is incomplete: add C++20 span, C++23 mdspan, flat_* |
- functions present in C++03 | |
- functions present since C++11 | |
- functions present since C++17 | |
- functions present since C++20 |
Non-member function table
This section is incomplete Reason: Create similar table for C++20 non-member container functions, e.g. erase_if, etc., and maybe begin/end families too. |
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 51 | C++98 | container iterators might be invalidated by arbitrary library operation |
they are only invalidated when specified |
See also
C++ named requirements:
- Container
- SequenceContainer
- ContiguousContainer
- ReversibleContainer
- AssociativeContainer
- AllocatorAwareContainer
- UnorderedAssociativeContainer
numeric arrays, array masks and array slices (class template) |