ForwardList#
Source file#
Interface#
-
template<ContainerElement T>
class ForwardList# A forward linked list.
A forward_list is a sequence container that supports forward iterators and allows constant time insert_after and erase_after operations anywhere within the sequence, with storage management handled automatically. Unlike vectors and deques, fast random access to forward_list elements is not supported, but many algorithms only need sequential access anyway.
Difference
Allocatoris not required as template parameter.Use dummpy head and tail nodes to simplify the implementation.
Not a circular forward_list (what libsdtc++ does).
Use
sizemember to support \(O(1)\)size()operation.
- 模板参数
T – Type of the elements stored in the nodes of forward_list.
Public Types
-
using allocator_traits = std::allocator_traits<allocator_type>#
-
using pointer = typename allocator_traits::pointer#
-
using const_pointer = typename allocator_traits::const_pointer#
-
using reference = value_type&#
-
using const_reference = const value_type&#
-
using size_type = std::size_t#
-
using difference_type = std::ptrdiff_t#
Public Functions
-
ForwardList()#
-
ForwardList(const ForwardList &other)#
-
ForwardList(ForwardList &&otherx)#
-
~ForwardList()#
-
ForwardList &operator=(const ForwardList &other)#
-
ForwardList &operator=(ForwardList &&other) noexcept(allocator_traits::propagate_on_container_move_assignment::value || allocator_traits::is_always_equal::value)#
-
ForwardList &operator=(std::initializer_list<T> ilist)#
-
allocator_type get_allocator() const noexcept#
-
const_iterator before_begin() const noexcept#
-
const_iterator begin() const noexcept#
-
const_iterator end() const noexcept#
-
const_iterator cbefore_begin() const noexcept#
-
const_iterator cbegin() const noexcept#
-
const_iterator cend() const noexcept#
-
bool empty() const noexcept#
-
const_reference front() const#
-
void pop_front()#
-
template<class ...Args>
iterator emplace_after(const_iterator pos, Args&&... args)#
-
iterator insert_after(const_iterator pos, const T &value)#
-
iterator insert_after(const_iterator pos, T &&value)#
-
iterator insert_after(const_iterator pos, size_type count, const T &value)#
-
template<std::input_iterator InputIt>
iterator insert_after(const_iterator pos, InputIt first, InputIt last)#
-
iterator insert_after(const_iterator pos, std::initializer_list<T> ilist)#
-
iterator erase_after(const_iterator pos)#
-
iterator erase_after(const_iterator first, const_iterator last)#
-
void swap(ForwardList &other) noexcept(allocator_traits::propagate_on_container_swap::value || allocator_traits::is_always_equal::value)#
-
void clear() noexcept#
-
void splice_after(const_iterator pos, ForwardList &other)#
-
void splice_after(const_iterator pos, ForwardList &&other)#
-
void splice_after(const_iterator pos, ForwardList &other, const_iterator it)#
-
void splice_after(const_iterator pos, ForwardList &&other, const_iterator it)#
-
void splice_after(const_iterator pos, ForwardList &other, const_iterator first, const_iterator last)#
-
void splice_after(const_iterator pos, ForwardList &&other, const_iterator first, const_iterator last)#
-
template<class UnaryPredicate>
size_type remove_if(UnaryPredicate pred)#
-
template<class BinaryPredicate>
size_type unique(BinaryPredicate binary_pred)#
-
void merge(ForwardList &other)#
-
void merge(ForwardList &&other)#
-
template<class Compare>
void merge(ForwardList &other, Compare comp)#
-
template<class Compare>
void merge(ForwardList &&other, Compare comp)#
-
void sort()#
-
void reverse() noexcept#