Changed
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
using namespace std;
|
||||
int main(){
|
||||
list<string> a;
|
||||
a.push_back("1.Ohyeah");
|
||||
a.push_back("2.Ohno");
|
||||
std::list<string>::iterator it = a.begin();
|
||||
auto ite = a.cbegin();
|
||||
cout << *ite << endl;
|
||||
a.insert(++it, "0.Ohoh");
|
||||
a.push_back("3.Ohhoho");
|
||||
for(string x : a){
|
||||
cout << x << " ";
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
//Copy a to b
|
||||
list<string> b(a);
|
||||
|
||||
auto itmp1 = a.begin();
|
||||
itmp1++;
|
||||
auto itmp2 = a.end();
|
||||
itmp2--;
|
||||
a.erase(itmp1, itmp2);
|
||||
|
||||
for(string x : a){
|
||||
cout << x << " ";
|
||||
}
|
||||
cout << endl << endl;
|
||||
//Two Methods going through The Whole List
|
||||
auto iit = a.begin();
|
||||
for(int i = 0; i < a.size(); i++){
|
||||
cout << *iit << " ";
|
||||
iit++;
|
||||
}
|
||||
cout << endl;
|
||||
cout << endl;
|
||||
|
||||
//insert ?
|
||||
for(string x : b){
|
||||
cout << x << " ";
|
||||
}
|
||||
cout << endl;
|
||||
auto itb = b.begin();
|
||||
itb++;itb++;
|
||||
b.insert(itb, a.begin(), a.end()); //insert into pos 2
|
||||
for(string x : b){
|
||||
cout << x << " ";
|
||||
}
|
||||
cout << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
BIN
LinearList/STL-List/main.exe
Normal file
BIN
LinearList/STL-List/main.exe
Normal file
Binary file not shown.
Reference in New Issue
Block a user