Cpp
priority_queue
- max heap by default
TODO Templates
template <typename T>
class myArray {
};
Vectors
<int> vec(5, 1); // vec of size 5 with default value of 1 vector
Queues
queue<int> q;
q.top();
q.push(1);
Maps
<string, int> map;
unordered_map.count("elem"); // 1 if it's in the map and 0 otherwise
map
if (map.find("val") != map.end()) {
}
// or
if (map.count("val")) {
}
Sets
std::unordered_set set;
.insert(1);
set.erase(1);
set
if (set.count("val")) {
}
Stacks
std::stack stack;
if (stack.empty()) {
}
Strings
std::isalnum(c);
std::tolower(c);
Finding a value in an array
.
Reversing stuff
std::reverse(str.begin(), str.end());