C++ <list> library
Iterators Related Functions
Function | Description |
---|---|
begin | Returns an iterator pointing to the first element of the list. Used for forward traversal. |
end | Returns an iterator pointing to the position after the last element of the list. Acts as the end marker for forward traversal. |
rbegin | Returns a reverse iterator pointing to the last element of the list. Used for reverse traversal. |
rend | Returns a reverse iterator pointing to the position before the first element of the list. Acts as the end marker for reverse traversal. |
cbegin | Returns a constant iterator pointing to the first element of the list. Ensures elements cannot be modified. |
cend | Returns a constant iterator pointing to the position after the last element of the list. Ensures elements cannot be modified. |
crbegin | Returns a constant reverse iterator pointing to the last element of the list. Ensures elements cannot be modified. |
crend | Returns a constant reverse iterator pointing to the position before the first element of the list. Ensures elements cannot be modified. |
Capacity Related Functions
Function | Description |
---|---|
empty | Checks whether the list is empty. Returns true if the list has no elements. |
size | Returns the number of elements in the list. |
max_size | Returns the maximum number of elements the list can theoretically hold. |
Element Access Related Functions
Function | Description |
---|---|
front | Accesses the first element of the list. |
back | Accesses the last element of the list. |
Modifiers Related Functions
Function | Description |
---|---|
assign | Replaces the contents of the list with new elements. |
emplace_front | Constructs and inserts an element at the beginning of the list. |
push_front | Adds an element to the beginning of the list. |
pop_front | Removes the first element of the list. |
emplace_back | Constructs and inserts an element at the end of the list. |
push_back | Adds an element to the end of the list. |
pop_back | Removes the last element of the list. |
emplace | Constructs and inserts an element at a specific position in the list. |
insert | Inserts elements at a specific position in the list. |
erase | Removes elements from the list at a specified position or range. |
swap | Exchanges the contents of two lists. |
resize | Changes the size of the list by adding or removing elements. |
clear | Removes all elements from the list, leaving it empty. |
Operations Related Functions
Function | Description |
---|---|
splice | Transfers elements from one list to another. |
remove | Removes all elements with a specific value. |
remove_if | Removes elements that satisfy a specified condition. |
unique | Removes consecutive duplicate elements from the list. |
merge | Merges two sorted lists into one sorted list. |
sort | Sorts the elements in the list. |
reverse | Reverses the order of elements in the list. |
Observers Related Functions
Function | Description |
---|---|
get_allocator | Returns the allocator associated with the list, which is used to handle memory allocation for its elements. |