Difference between revisions of "cpp/container/forward list"
(update par) |
m (Shorten template names. Use {{lc}} where appropriate.) |
||
Line 8: | Line 8: | ||
}} | }} | ||
− | {{tt|std::forward_list}} is a container that supports fast insertion and removal of elements from anywhere in the container. Fast random access is not supported. It is implemented as singly-linked list and essentially does not have any overhead compared to its implementation in C. Compared to {{ | + | {{tt|std::forward_list}} is a container that supports fast insertion and removal of elements from anywhere in the container. Fast random access is not supported. It is implemented as singly-linked list and essentially does not have any overhead compared to its implementation in C. Compared to {{lc|std::list}} this container provides more space efficient storage when bidirectional iteration is not needed. |
Addition, removal and moving the elements within the list or across several lists does not invalidate the iterators. An iterator is invalidated only when the corresponding element is deleted. | Addition, removal and moving the elements within the list or across several lists does not invalidate the iterators. An iterator is invalidated only when the corresponding element is deleted. | ||
Line 21: | Line 21: | ||
===Member types=== | ===Member types=== | ||
− | {{ | + | {{dsc begin}} |
− | {{ | + | {{dsc hitem | Member type | Definition}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list value_type | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list allocator_type | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list size_type | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list difference_type | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list reference | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list const_reference | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list pointer | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list const_pointer | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list iterator | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list const_iterator | forward_list}} |
− | {{ | + | {{dsc end}} |
===Member functions=== | ===Member functions=== | ||
− | {{ | + | {{dsc begin}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list constructor | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list destructor | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list operator{{=}} | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list assign | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list get_allocator | forward_list}} |
− | {{ | + | {{dsc h2 | Element access}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list front | forward_list}} |
− | {{ | + | {{dsc h2 | Iterators}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list before_begin | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list begin | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list end | forward_list}} |
− | {{ | + | {{dsc h2 | Capacity}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list empty | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list max_size | forward_list}} |
− | {{ | + | {{dsc h2 | Modifiers}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list clear | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list insert_after | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list emplace_after | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list erase_after | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list push_front | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list emplace_front | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list pop_front | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list resize | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list swap | forward_list}} |
− | {{ | + | {{dsc h2 | Operations}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list merge | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list splice_after | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list remove | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list reverse | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list unique | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list sort | forward_list}} |
− | {{ | + | {{dsc end}} |
===Non-member functions=== | ===Non-member functions=== | ||
− | {{ | + | {{dsc begin}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list operator_cmp | forward_list}} |
− | {{ | + | {{dsc inc | cpp/container/dcl list swap2 | forward_list}} |
− | {{ | + | {{dsc end}} |
[[de:cpp/container/forward list]] | [[de:cpp/container/forward list]] |
Revision as of 18:39, 31 May 2013
Defined in header <forward_list>
|
||
template< class T, |
(since C++11) | |
std::forward_list
is a container that supports fast insertion and removal of elements from anywhere in the container. Fast random access is not supported. It is implemented as singly-linked list and essentially does not have any overhead compared to its implementation in C. Compared to std::list this container provides more space efficient storage when bidirectional iteration is not needed.
Addition, removal and moving the elements within the list or across several lists does not invalidate the iterators. An iterator is invalidated only when the corresponding element is deleted.
std::forward_list
meets the requirements of Template:concept (except for the size()
member function), Template:concept and Template:concept.
Contents |
Template parameters
T | - | The type of the elements.
| ||||
Allocator | - | An allocator that is used to acquire/release memory and to construct/destroy the elements in that memory. The type must meet the requirements of Allocator. The behavior is undefined(until C++20)The program is ill-formed(since C++20) if Allocator::value_type is not the same as T .
|