forward_list Class

描述控制不同的长度序列的元素的对象。将序列被视为内单向链接列表中的节点,每个包含类型的成员Type。

template<class Type, class Allocator = allocator<Type> >
    class forward_list {
public:
    typedef Allocator allocator_type;
    typedef typename Allocator::pointer pointer;
    typedef typename Allocator::const_pointer
        const_pointer;
    typedef typename Allocator::reference reference;
    typedef typename Allocator::const_reference const_reference;
    typedef typename Allocator::value_type value_type;
    typedef typename Allocator::size_type size_type;
    typedef typename Allocator::difference_type difference_type;

    typedef T0 iterator;
    typedef T1 const_iterator;

    forward_list();
    explicit forward_list(const Allocator& _Alloc);
    explicit forward_list(size_type _Count);
    forward_list(
        size_type _Count, 
        const Type& _Val
    );
    forward_list(
        size_type _Count, 
        const Type& _Val, 
        const Allocator& _Alloc
    );
    forward_list(const forward_list& _Right);
    template<class InputIterator>
        forward_list (
            InputIterator _First, 
            InputIterator _Last
);
    template<class InputIterator>
        forward_list (
            InputIterator _First,
            InputIterator _Last, 
            const Allocator& _Alloc
);

    forward_list (initializer_list<Type> _Init)
    forward_list (
        initializer_list<Type> _Init,
        const Allocator& _Alloc
);
    forward_list (forward_list&& _Right);
 
    ~forward_list();

    forward_list& operator= (const forward_list& _Right);
    forward_list& operator= (forward_list&& _Right);

    iterator before_begin ();
    const_iterator before_begin () const;
    iterator begin ();
    const_iterator begin () const;
    iterator end ();
    const_iterator end () const;

    const_iterator cbefore_begin () const;
    const_iterator cbegin () const;
    const_iterator cend () const;

    void resize (size_type _Count);
    void resize (
        size_type _Count, 
        const Type& _Val
    );
    size_type max_size () const;
    bool empty () const;

    Alloc get_allocator () const;

    reference front ();
    const_reference front () const;

    void push_front (const Type& _Val);
    void push_front (Type&& _Val);
    template<class _Type>
        void emplace_front(_Type&& _Val);
    void pop_front ();

    template<class InputIterator>
        void assign (
            InputIterator _First, 
            InputIterator _Last
);
    void assign (
        size_type _Count, 
        const Type& _Val
    );

    iterator insert_after (
        const_iterator _Pos, 
        const Type& _Val
    );
    void insert_after (
        const_iterator _Pos, 
        size_type _Count, 
        const Type& _Val
    );
    template<class InputIterator >
        void insert_after (
            const_iterator _Pos, 
            InputIterator _First, 
            InputIterator _Last
        );
    void insert_after (
        const iterator _Pos, 
        initializer_list<Type> _Init
)
    iterator insert_after (
        const_iterator _Pos, 
        Type&& _Val
    );
    template<class Type>
        iterator emplace_after(const_iterator _Where, Type&& _Val);
    iterator erase_after (const_iterator _Pos);
    iterator erase_after (
        const_iterator _First, 
        const_iterator _Last
    );
    void clear ();

    void swap (forward_list& _Right);

    void splice_after (
        const_iterator _Pos, 
        forward_list& _List
    );
    void splice_after (
        const_iterator _Pos, 
        forward_list& _List, 
        iterator _First
    );
    void splice_after (
        const_iterator _Pos, 
        forward_list& _List, 
        iterator _First,
        iterator _Last);

    void remove (const Type& _Val);
    template<class Predicate>
        void remove_if (Predicate _Pred);
    void unique ();
    template<class BinaryPredicate>
        void unique (BinaryPredicate _Comp);

    void merge (forward_list& _List);
    template<class BinaryPredicate>
        void merge (
            forward_list& _List, 
            BinaryPredicate _Comp
);
    void sort ();
    template<class BinaryPredicate>
        void sort (BinaryPredicate _Comp);
    void reverse ();
};

参数

Parameter

说明

Type

存储在 forward_list 元素数据类型。

_Alloc

存储分配器对象封装有关 forward_list 分配和解除分配的内存的详细信息。此参数是可选的。默认值是分配器 <Type>。

_Count

在 forward_list 中的元素数。

_Val

要添加到元素forward_list

_Right

该列表将合并到forward_list

_Pos

迭代器中的某个位置,该值指示forward_list

_First

指示某个范围中的元素的开始位置的迭代器forward_list

_Last

指示某个范围中的元素的结束位置的迭代器forward_list

_Init

初始值设定项列表

_List

若要合并、 拼接,或从指定的 forward_list。

_Comp

比较函数。

备注

A forward_list对象分配和释放存储,它通过存储对象类的控制序列Allocator的基于allocator Class (通常称为std::allocator)。有关更多信息,请参见 分配器。分配器对象必须具有相同的外部界面模板类的对象allocator

说明说明

当分配的容器对象,则不会复制的存储分配器对象。

迭代器、 指针和引用可能会变得无效时其受控序列的元素都会被清除,通过forward_list。通过受控序列在执行插入操作和接头forward_list不使迭代器。

添加受控序列的内容可能会通过调用forward_list::insert_after,这是唯一的成员函数调用的构造函数的Type(const _Type&)。forward_list也可能调用移动构造函数。如果这样的表达式,将引发异常,容器对象插入任何新的元素,并再次引发异常。因此,模板类的对象forward_list这类异常发生时处于已知状态。

Ee373559.collapse_all(zh-cn,VS.110).gif构造函数

forward_list

构造类型的对象forward_list。

Ee373559.collapse_all(zh-cn,VS.110).gifTypedef

allocator_type

表示一个正向列表对象的分配器类的类型。

const_iterator

为转发列表中提供了一个常量的迭代器的类型。

const_pointer

提供链接指向的类型const正向列表中的元素。

const_reference

提供转发列表中的元素的常量引用的类型。

difference_type

可用于表示正向列表迭代器所指向的元素之间的区域中的元素数的有符号的整数类型。

迭代器

为转发列表中提供了一个迭代器的类型。

pointer

提供指向转发列表中的元素的类型。

引用

提供转发列表中的元素的引用类型。

size_type

一种类型,表示两个元素之间的无符号的距离。

value_type

表示存储在一个正向列表中的元素的类型的类型。

Ee373559.collapse_all(zh-cn,VS.110).gif成员函数

assign

会删除正向列表中的元素,并将一组新的元素复制到目标前进的列表。

before_begin

返回迭代器寻址的第一个元素之前正向列表中的位置。

begin

返回迭代器寻址正向列表中的第一个元素。

cbefore_begin

返回常量迭代器寻址的第一个元素之前正向列表中的位置。

cbegin

返回常量迭代器寻址正向列表中的第一个元素。

cend

返回用于解决成功正向列表中的最后一个元素的位置的常数迭代器。

clear

清除转发列表中的所有元素。

emplace_after

移动构造一个新元素后的指定位置。

emplace_front

添加一个构造在列表的开头位置的元素。

empty

测试是否正向列表为空。

end

返回一个迭代器,解决了成功的正向列表中的最后一个元素的位置。

erase_after

指定位置之后,请从转发列表中移除元素。

front

返回正向列表中的第一个元素的引用。

get_allocator

返回用于构造正向列表分配器对象的副本。

insert_after

将元素添加到转发列表中,指定位置之后。

max_size

返回正向列表中的最大长度。

merge

从参数列表中移除的元素、 将它们插入到目标正向列表中,新的组合升序排序或其他指定的顺序中的元素集进行排序。

pop_front

删除正向列表的开头处的元素。

push_front

正向列表的开头添加一个元素。

remove

清除与指定的值匹配的正向列表中的元素。

remove_if

擦除满足指定的谓词时正向列表中的元素。

resize

指定正向列表的新大小。

反向

将元素正向列表中的出现的顺序颠倒。

sort

排列元素按升序排列或与指定谓词的顺序。

splice_after

Restitches 节点之间的链接。

换用

交换两个正向列表中的元素。

unique

移除通过指定测试的相邻元素。

Ee373559.collapse_all(zh-cn,VS.110).gif运算符

operator=

转发列表中的元素替换另一个正向列表的副本。

要求

标题: <forward_list>

命名空间: 标准

请参见

参考

<forward_list>

其他资源

forward_list 成员