---
# System prepended metadata

title: STL

---

# STL
```
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;

void vec();	//vector
void SET(); //set
void MAP(); //map
void que(); //queue
void sta(); //stack
void pri(); //Priority queue

int main()
{
    vec();
    cout << "=============================" << endl;
    SET();
    cout << "=============================" << endl;
    MAP();
    cout << "=============================" << endl;
    que();
    cout << "=============================" << endl;
    sta();
    cout << "=============================" << endl;
    pri();
}

void vec()
{
    vector<int> a;
    int i;
    for(i = 0; i < 10; i++) {
        a.push_back(i);
    }

    a.insert(a.begin() + 5, 999);

    vector<int>::iterator it = find(a.begin(), a.end(), 6);
    for (i = 0; i < a.size(); i++) {
        cout << a[i] << endl;
    }
}

void SET()
{
    set<int> a;
    for(int i = 10; i < 100; i += 10)
        a.insert(i);


    cout << a.count(70) << endl;

    a.erase(30);

    for (auto it = a.begin(); it != a.end(); ++it)
        cout << *it << endl;
}

void MAP()
{
    map<string, int> a;

    a["一"] = 1;
    a["二"] = 2;
    a["三"] = 3;

    a.insert(pair<string, int>("四", 4));

    a.find("三");

    a.erase("一");	//delete

    cout << a["二"] << endl;
    cout << a["三"] << endl;
    cout << a["四"] << endl;
}
void que()
{
    queue<int> a;
    a.push(10);
    a.push(20);
    a.push(30);

    while (a.size()) {
        cout << a.front() << endl;
        a.pop();
    }
}

void sta()
{
    stack <int> a;
    int i;
    for(i = 0; i <= 11; i++)
        a.push(i);

    a.pop();

    while(a.size()) {
        cout << a.top() << endl;
        a.pop();
    }


}

void pri()
{
    priority_queue <int> a;
    a.push(2);
    a.push(23);
    a.push(21);
    a.push(7);

    while (a.size()) {
        cout << a.top() << endl;
        a.pop();
    }
}
```