Skip to content

Instantly share code, notes, and snippets.

@rodorgas
Created July 24, 2018 03:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodorgas/d8258a3118035acaedf66d64a35e8f19 to your computer and use it in GitHub Desktop.
Save rodorgas/d8258a3118035acaedf66d64a35e8f19 to your computer and use it in GitHub Desktop.

funções da stl

queue

push(x) no final da fila, pop(x), front(x) retorna o valor do 1o. elemento da fila, size(), empty()

queue<int> q;
q.push(1);
print(q.front());
q.pop();

stack

push(x) no topo da pilha, pop(x), top()

stack<int> st;
st.push(1);
st.push(2);
st.pop();
print(st.top()); // 1

analogia: pilha de pratos. não tem índice.

vector

  • push_back(x): insere o elemento x no final
  • pop_back(): remove o último elemento
  • [i]: retorna a i-ésima posição
  • size()
  • clear(): limpa o vetor
  • back()
vector<int> v;
v.push_back(3);
v.push_back(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment