c++ 类库中list中的函数有哪些
#include<list>lista;请问通过a可以调用的函数有哪些,具体功能是什么?求教求教...
#include<list>list a;请问通过a可以调用的函数有哪些,具体功能是什么?求教求教
展开
2个回答
展开全部
常用到的就几个:
假如list <int> a;//创建整型链表 a
list <int>::iterator it;//迭代器
1.a.push_back(1);//向list尾部插入数据1。
2.a.push_front(2);向list头部插入数据2。
3.a.reverse();//将list倒置
4.a.erase(it);//删除it指向的数据
5.a.insert(it,100);//在it前插入一个数100
6.it=a.begin();//it指向a的开头
7.it=a.end();//it指向a的结束
假如list <int> a;//创建整型链表 a
list <int>::iterator it;//迭代器
1.a.push_back(1);//向list尾部插入数据1。
2.a.push_front(2);向list头部插入数据2。
3.a.reverse();//将list倒置
4.a.erase(it);//删除it指向的数据
5.a.insert(it,100);//在it前插入一个数100
6.it=a.begin();//it指向a的开头
7.it=a.end();//it指向a的结束
展开全部
Member functions
(constructor) Construct list (public member function)
(destructor) List destructor (public member function)
operator= Copy container content (public member function )
Iterators:
begin Return iterator to beginning (public member function)
end Return iterator to end (public member function )
rbegin Return reverse iterator to reverse beginning (public member function)
rend Return reverse iterator to reverse end (public member function)
Capacity:
empty Test whether container is empty (public member function)
size Return size (public member function)
max_size Return maximum size (public member function )
resize Change size (public member function)
Element access:
front Access first element (public member function )
back Access last element (public member function)
Modifiers:
assign Assign new content to container (public member function)
push_front Insert element at beginning (public member function)
pop_front Delete first element (public member function)
push_back Add element at the end (public member function)
pop_back Delete last element (public member function)
insert Insert elements (public member function)
erase Erase elements (public member function)
swap Swap content (public member function )
clear Clear content (public member function)
Operations:
splice Move elements from list to list (public member function)
remove Remove elements with specific value (public member function)
remove_if Remove elements fulfilling condition (public member function template )
unique Remove duplicate values (member function )
merge Merge sorted lists (public member function )
sort Sort elements in container (public member function )
reverse Reverse the order of elements (public member function )
Allocator:
get_allocator Get allocator (public member function )
(constructor) Construct list (public member function)
(destructor) List destructor (public member function)
operator= Copy container content (public member function )
Iterators:
begin Return iterator to beginning (public member function)
end Return iterator to end (public member function )
rbegin Return reverse iterator to reverse beginning (public member function)
rend Return reverse iterator to reverse end (public member function)
Capacity:
empty Test whether container is empty (public member function)
size Return size (public member function)
max_size Return maximum size (public member function )
resize Change size (public member function)
Element access:
front Access first element (public member function )
back Access last element (public member function)
Modifiers:
assign Assign new content to container (public member function)
push_front Insert element at beginning (public member function)
pop_front Delete first element (public member function)
push_back Add element at the end (public member function)
pop_back Delete last element (public member function)
insert Insert elements (public member function)
erase Erase elements (public member function)
swap Swap content (public member function )
clear Clear content (public member function)
Operations:
splice Move elements from list to list (public member function)
remove Remove elements with specific value (public member function)
remove_if Remove elements fulfilling condition (public member function template )
unique Remove duplicate values (member function )
merge Merge sorted lists (public member function )
sort Sort elements in container (public member function )
reverse Reverse the order of elements (public member function )
Allocator:
get_allocator Get allocator (public member function )
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询