C++ <list> library

Iterators Related Functions

FunctionDescription
beginReturns an iterator pointing to the first element of the list. Used for forward traversal.
endReturns an iterator pointing to the position after the last element of the list. Acts as the end marker for forward traversal.
rbeginReturns a reverse iterator pointing to the last element of the list. Used for reverse traversal.
rendReturns a reverse iterator pointing to the position before the first element of the list. Acts as the end marker for reverse traversal.
cbeginReturns a constant iterator pointing to the first element of the list. Ensures elements cannot be modified.
cendReturns a constant iterator pointing to the position after the last element of the list. Ensures elements cannot be modified.
crbeginReturns a constant reverse iterator pointing to the last element of the list. Ensures elements cannot be modified.
crendReturns a constant reverse iterator pointing to the position before the first element of the list. Ensures elements cannot be modified.

Capacity Related Functions

FunctionDescription
emptyChecks whether the list is empty. Returns true if the list has no elements.
sizeReturns the number of elements in the list.
max_sizeReturns the maximum number of elements the list can theoretically hold.

Element Access Related Functions

FunctionDescription
frontAccesses the first element of the list.
backAccesses the last element of the list.

Modifiers Related Functions

FunctionDescription
assignReplaces the contents of the list with new elements.
emplace_frontConstructs and inserts an element at the beginning of the list.
push_frontAdds an element to the beginning of the list.
pop_frontRemoves the first element of the list.
emplace_backConstructs and inserts an element at the end of the list.
push_backAdds an element to the end of the list.
pop_backRemoves the last element of the list.
emplaceConstructs and inserts an element at a specific position in the list.
insertInserts elements at a specific position in the list.
eraseRemoves elements from the list at a specified position or range.
swapExchanges the contents of two lists.
resizeChanges the size of the list by adding or removing elements.
clearRemoves all elements from the list, leaving it empty.

Operations Related Functions

FunctionDescription
spliceTransfers elements from one list to another.
removeRemoves all elements with a specific value.
remove_ifRemoves elements that satisfy a specified condition.
uniqueRemoves consecutive duplicate elements from the list.
mergeMerges two sorted lists into one sorted list.
sortSorts the elements in the list.
reverseReverses the order of elements in the list.

Observers Related Functions

FunctionDescription
get_allocatorReturns the allocator associated with the list, which is used to handle memory allocation for its elements.