diff --git a/STL.cpp b/STL.cpp new file mode 100644 index 000000000..7868d3212 --- /dev/null +++ b/STL.cpp @@ -0,0 +1,325 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; +int main() +{ + cout<v1; //syntax for declaring a vector + v1.push_back(1); //enter a value in vector + v1.push_back(2); + v1.push_back(3); + v1.push_back(4); + cout<<"values of v1--"<v2; + v2={10,20,30}; //another method of inputing values in vector + cout<v3; + v3={6,4,10,8}; + cout<<"values of v3 before sort function--"<p1; //syntax to declare a pair + p1.first=17; //syntax to declare the 1st element of the pair + p1.second='s'; //syntax to declare 2nd element of the pair + cout<arr={1,2,3,4,5}; //implementation of int type array of size 5 + cout<<"1st element -- "<d; + d.push_back(2); //inputs value at back + d.push_back(1); + d.push_back(3); + d.push_front(4); //inputs value at front + cout<l; //implementing list + l.push_back(2); //enter the value at last + l.push_back(1); + l.push_front(0); //enter value at front + cout<st; + st.push(2); + st.push(0); + st.push(7); + st.push(25); //last in + int stsize=st.size(); //gives size of stack + cout<<"\n size of stack--- "<qu; + qu.push(23); + qu.push(67); + qu.push(46); + qu.push(65);//first in + qu.pop(); //first out + cout<<"\n front-- "<max; //implementation of priority queue prints value from higher to lower + max.push(35); + max.push(87); + max.push(100); + cout<<"prints in decessending order..."<,greater>min; //implementation of priority queue prints value from lower to higher + min.push(100); + min.push(35); + min.push(87); + cout<<"prints in acessending order..."<set1; //implement + set1.insert(12); //inserting values + set1.insert(12); + set1.insert(12); + set1.insert(6); + set1.insert(0); + set1.insert(12); + set1.insert(4); + for(auto i:set1) + { + cout<map1; //implement of map having int type pointer and char type value + map1[2]='a'; + map1[1]='b'; + map1[3]='c'; + map1[1]='b'; + map1[1]='d'; + map1[2]='z'; + cout<<"output of pointers in map..."<