Sequential Containers in C STL Definition of Sequential

















































- Slides: 49

Sequential Containers in C++ STL 曹雨森

Definition of Sequential Containers • Sequence containers refer to a group of container class templates that implement storage of data elements. • Being templates, they can be used to store arbitrary elements, such as integers or custom classes. • All sequential containers is that the elements can be accessed sequentially. • Like all other standard library components, they reside in namespace std.








vector



增加函数 • void push_back(const T or x): 向量尾部增加一个元素X • iterator insert(iterator it, const T or x): 向量中迭代器指向元素前增加一个元素 x • iterator insert(iterator it, int n, const T or x): 向量中迭代器指向元素前增加n个 相同的元素x • iterator insert(iterator it, const_iterator first, const_iterator last): 向量中迭代器 指向元素前插入另一个相同类型向量的[first, last)间的数据 举几个例子 vec. insert(vec. end(), 10, "hello") 在vec的末尾插入 10个“hello”元素 vec. insert(vec. end(), { "xx", "yy", "zz", "kk" }) 在vec后�插入四个 string,分�� "xx", "yy", "zz", "kk" vec. insert(it 1, it 2, it 3) 将[it 2, it 3)范�内的元素插入到 it 1之前










list



forward_list



deque





string









• 替换子串 replace 成员函数可以对 string 对象中的子串进行替换,返回值为对象自身 的引用。 例如: string s 1("Problem Solving"); s 1. replace(0, 7, "123456", 0, 3); //用 "123456" 的子串(0, 3) 替 换 s 1 的子串(0, 7) cout << s 1 << endl; //输出 123 Solving string s 2("ant ant"); s 2. replace(0, 3, 5, 'a'); //用 5 个 'a' 替换子串(0, 3) cout << s 2 << endl; //输出 aaaaa ant int n = s 2. find("aaaaa"); //查找子串 "aaaaa" 的位置,n=0 s 2. replace(n, 5, "horse"); //将子串(n, 5)替换为"horse" cout << s 2 << endl; //输出 horse ant





参考资料 • Chapters 3 and 9 of C++ Primer (5 th Edition) • Sequence container (C++) @ wiki https: //en. wikipedia. org/wiki/Sequence_container_(C%2 B%2 B)

Thanks for Your Listening
Cs 247
What goes in black pharmaceutical waste containers
Liquid is pouring into a container at a constant rate
Hpe greenlake containers
Cidex opa solution log sheet
Sgx linux
Containers quantifiers
Containers lesson plan
Java swing container
Associative containers
Containers as a service
For clarity of aqueous extract test container autoclaved at
Boyle's law in real life
Linux containers (lxc)
Anchor container security
Chdpe
Pete and pete container
Water attack test for glass
Accompaniments garnishes and decorations for desserts
Returnable containers accounting
Baie container
Rigid sterilization containers
Hyperv container
Four containers were filled with warm water
Containers for change
How to find partial pressure from total pressure
Empty swing
Ancient greek containers
Rapid prototyping data formats
Biblioteka stl
Generic programming and the stl
Stl functors
Projet stl exemple
From statsmodels.tsa.seasonal import stl
Terminale stl spcl systèmes et procédés
Biblioteka stl
Std sort
Stl biblioteka
Prigent stl
Libreria stl
Parallel stl
Stl stands for in c++
Sandefjordskolen stl+
Stepanov stl
Stl bgb
What wind is forecast for stl at 12 000 feet
Of what value is the weather depiction chart to the pilot?
Thư viện stl
Stl link st leonards
Formato obj