Fork me on GitHub
摘要: list.front(); //返回第一个元素 list.back(); //返回最后一个元素 1 #include <iostream> 2 #include <list> 3 4 using namespace std; 5 6 int main() 7 { 8 int num[] = { 11 阅读全文
posted @ 2020-05-04 21:43 索智源 阅读(358) 评论(0) 推荐(0) 编辑
摘要: list.assign(beg, end); //将[beg, end)区间中的数据拷贝赋值给本身 1 #include <iostream> 2 #include <list> 3 4 using namespace std; 5 6 int main() 7 { 8 int num[] = { 阅读全文
posted @ 2020-05-04 21:35 索智源 阅读(1115) 评论(0) 推荐(0) 编辑
摘要: ist.size(); //返回容器中元素的个数 1 #include <iostream> 2 #include <list> 3 4 using namespace std; 5 6 int main() 7 { 8 int num[] = { 111,222,333,444,555 }; 9 阅读全文
posted @ 2020-05-04 21:34 索智源 阅读(899) 评论(0) 推荐(0) 编辑
摘要: push_back(elem); //在容器尾部加入一个元素 1 #include <iostream> 2 #include <list> 3 4 using namespace std; 5 6 int main() 7 { 8 int num[] = { 111,222,333 }; 9 li 阅读全文
posted @ 2020-05-04 20:56 索智源 阅读(1439) 评论(7) 推荐(0) 编辑
摘要: list<T> lstT —— list 对象的默认构造 list 与 vector 一样,同样采用模板类实现,对象的默认构造形式:list<T> lstT 如: 1 #include <iostream> 2 #include <list> 3 4 using namespace std; 5 6 阅读全文
posted @ 2020-05-04 19:51 索智源 阅读(781) 评论(0) 推荐(0) 编辑