ForwardList#

Source file#

ChaiGO container/sequence/forward_list

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

  • Allocator is not required as template parameter.

  • Use dummpy head and tail nodes to simplify the implementation.

  • Not a circular forward_list (what libsdtc++ does).

  • Use size member to support \(O(1)\) size() operation.

模板参数

T – Type of the elements stored in the nodes of forward_list.

Public Types

using value_type = T#
using node_type = ForwardListNode<T>#
using allocator_type = allocator<node_type>#
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#
using iterator = ForwardListIterator<T>#
using const_iterator = ForwardListConstIterator<T>#

Public Functions

ForwardList()#
explicit ForwardList(size_type count, const T &value = T())#
template<std::input_iterator InputIt>
ForwardList(InputIt first, InputIt last)#
ForwardList(const ForwardList &other)#
ForwardList(ForwardList &&otherx)#
ForwardList(std::initializer_list<T> ilist)#
~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)#
template<std::input_iterator InputIt>
void assign(InputIt first, InputIt last)#
void assign(size_type count, const T &value)#
void assign(std::initializer_list<T> ilist)#
allocator_type get_allocator() const noexcept#
iterator before_begin() noexcept#
const_iterator before_begin() const noexcept#
iterator begin() noexcept#
const_iterator begin() const noexcept#
iterator end() 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#
size_type size() const noexcept#
size_type max_size() const noexcept#
void resize(size_type count)#
void resize(size_type count, const T &value)#
reference front()#
const_reference front() const#
template<class ...Args>
reference emplace_front(Args&&... args)#
void push_front(const T &value)#
void push_front(T &&value)#
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)#
size_type remove(const T &value)#
template<class UnaryPredicate>
size_type remove_if(UnaryPredicate pred)#
size_type unique()#
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()#
template<class Compare>
void sort(Compare comp)#
void reverse() noexcept#