list stl

Solutions on MaxInterview for list stl by the best coders in the world

showing results for - "list stl"
Sofia
26 Jun 2020
1#include <algorithm>
2#include <iostream>
3#include <list>
4 
5int main()
6{
7    // Create a list containing integers
8    std::list<int> l = { 7, 5, 16, 8 };
9 
10    // Add an integer to the front of the list
11    l.push_front(25);
12    // Add an integer to the back of the list
13    l.push_back(13);
14 
15    // Insert an integer before 16 by searching
16    auto it = std::find(l.begin(), l.end(), 16);
17    if (it != l.end()) {
18        l.insert(it, 42);
19    }
20 
21    // Print out the list
22    std::cout << "l = { ";
23    for (int n : l) {
24        std::cout << n << ", ";
25    }
26    std::cout << "};\n";
27}
Christian
10 Nov 2017
1#include <iostream>
2#include<list>
3#include<algorithm>
4
5using namespace std;
6
7int main()
8{
9    list<int>l{10,20,30};
10    for(list<int>::iterator it1=l.begin();it1!=l.end();it1++)
11    {
12        cout<<*it1<<" ";
13    }
14    cout<<endl;
15    list<int>::iterator it=l.begin();
16    l.insert(it,50);
17    for(list<int>::iterator it1=l.begin();it1!=l.end();it1++)
18    {
19        cout<<*it1<<" ";
20    }
21    cout<<endl;
22    l.push_back(60);
23    l.push_front(100);
24    for(list<int>::iterator it1=l.begin();it1!=l.end();it1++)
25    {
26        cout<<*it1<<" ";
27    }
28    cout<<endl;
29    l.pop_back();
30    l.pop_front();
31    for(list<int>::iterator it1=l.begin();it1!=l.end();it1++)
32    {
33        cout<<*it1<<" ";
34    }
35    cout<<endl;
36    cout<<l.empty()<<endl;
37    l.reverse();
38    for(list<int>::iterator it1=l.begin();it1!=l.end();it1++)
39    {
40        cout<<*it1<<" ";
41    }
42    cout<<endl;
43    list<int>l2{100,200,300,400};
44    l.swap(l2);
45    for(list<int>::iterator it1=l.begin();it1!=l.end();it1++)
46    {
47        cout<<*it1<<" ";
48    }
49    cout<<endl;
50    for(list<int>::iterator it1=l2.begin();it1!=l2.end();it1++)
51    {
52        cout<<*it1<<" ";
53    }
54    cout<<endl;
55    l2.sort();
56    for(list<int>::iterator it1=l2.begin();it1!=l2.end();it1++)
57    {
58        cout<<*it1<<" ";
59    }
60    cout<<endl;
61    l2.sort(greater<int>());
62    for(list<int>::iterator it1=l2.begin();it1!=l2.end();it1++)
63    {
64        cout<<*it1<<" ";
65    }
66    cout<<endl;
67    cout<<"--------"<<endl;
68     l.sort();
69     l2.sort();
70     l.merge(l2);
71     for(list<int>::iterator it1=l.begin();it1!=l.end();it1++)
72    {
73        cout<<*it1<<" ";
74    }
75    cout<<endl;
76    cout<<endl;
77    return 0;
78}
79
Arianna
28 Feb 2018
1template < class T, class Alloc = allocator<T> > class list;
queries leading to this page
lists in stllinkedlist stllist c 2b 2b examplehittable list cpplist using stlstl linked listyc 2b 2b stl header liststl list array c 2b 2bc 2b 2b how to implement a listinbuilt linked list in c 2b 2bstl listscpp std list examplewhat is an stl liststd list c 2b 2blist c stl listlist int in c 2b 2blist of stldoes stl work in linked list c 2b 2bexample of std 3a 3alist use c 2b 2binclude c 2b 2b listlinked list stlc 2b 2b library for linked listlist functions c 2b 2blist in std c 2b 2bimplementation your own list stl in c 2b 2bc 2b 2b std function listlist iin c 2b 2b list libraryset stlcpp list examplecpp listlist stllist cpp stllist of strings in c 2b 2b stlstl list examplelinked lists stl c 2b 2bcpp stl listlist operations in c 2b 2blinked list c 2b 2b librarylist in stllinked list in stl in c 2b 2bc 2b 2b stl linked listlist stl c 2b 2bstd list cpplista stlstl list in c 2b 2bsozling linkedlist questions using stl c 2b 2blist in cpplinkedlist c 2b 2b stllist of std methods c 2b 2bunordered list vector c 2b 2blist stl functionscpp std listusing std list c 2b 2bstl linked listc 2b 2b reference listlist std c 2b 2blist std c 2b 2b code examplelist in cpp stlhow to use inbuilt linked list in c 2b 2blist in c 2b 2b stlcpp std list allocatorlinked list library c 2b 2bcreate std 3a 3alist cpplinked list using stlstl data structres linked listlinklist stlbest type of list c 2b 2bcppreference liststd 3a 3alist 3c 3e cpplist c 2b 2blinked list implementation in c 2b 2b stllist cpp metodsc 2b 2b basic listc 2b 2b std listcpp list methodslist in stl c 2b 2bc 2b 2b list examplestd 3a 3alist examples in cppc 2b 2b listlist of std 3a 3afunctiondoubly linked list in stl 23include list in c 2b 2bc 2b 2b list templatehow to define a list in c 2binclude linked list c 2b 2blist stlusing std 3a 3alist in c 2b 2blist data structure c 2b 2bsequence list cpplist functions in c 2b 2bhow to access elements of a list in c 2b 2bstl list implementation in c 2b 2blist in c 2b 2bcpp are std 3a 3alist linked listll in c 2b 2b stllist of all method in std cppc 2b 2b std list libraryhow to list strdoubly linked list in c 2b 2b stlcpp for liststd list code c 2b 2bc 2b 2b list stdlibrary for linked list in c 2b 2bstd listlist of int c 2b 2b implementation codelist c 2b 2b referencelist structure in stllist stl in c 2b 2bhow to use a stl listc 2b 2b linked list librarylist stl specificationlinked list sing stllist cppstd 3a 3alist cpplineear traversing through list in cpp stllink list stl c 2b 2ball std list c 2b 2blist in stl cpplinked list std c 2b 2blist get in c 2b 2blist in c 2b 2b 3bc 2b 2b all list container functionsdoubly linked list stllinked list in stl c 2b 2bhow to recreate a list cppcpp list of stringslinked list c 2b 2b stllist in c 2b 2b 27include lis c 2b 2blist stl