C++ Toolbox
Vector
Find an element in an array
Simple version:
Generic version:
Sort
Sort vector of vector: https://stackoverflow.com/questions/14419520/sort-vector-of-vectors
Sum of vector elements: https://stackoverflow.com/questions/3221812/how-to-sum-up-elements-of-a-c-vector
String
pop_back
convert string to int - stoi http://www.cplusplus.com/reference/string/stoi/
convert string element to int (or back)
https://stackoverflow.com/questions/5290089/how-to-convert-a-number-to-string-and-vice-versa-in-c
Convert int to char
In C++17, use std::to_chars as:
In C++11, use std::to_string as:
Priority_queue
Create a min-heap:
Store my own data structure:https://stackoverflow.com/questions/16111337/declaring-a-priority-queue-in-c-with-a-custom-comparator/48587737
Set
Custom comparator
Last updated