snippet bare "barebone code template" #include #include #include using std::cout; using std::endl; using std::vector; using std::string; int main() { return 0; } endsnippet snippet icd "#include directive" b #include <$1> $0 endsnippet snippet plist "print vector" w template void printList(const T& arr, const string& desc){ std::cout << desc << ": ["; for (auto it = arr.begin(); it != arr.end(); it++){ std::cout << *it << ((std::next(it) != arr.end()) ? ", " : "]\n"); } } endsnippet snippet pmat "print list of list" w template void printMat(const vector>& mat, const string& desc){ cout << desc << ": " << endl; for (auto it1 = mat.begin(); it1 != mat.end(); it1++){ auto cur_vec = *it1; for (auto it2 = cur_vec.begin(); it2 != cur_vec.end(); it2++){ cout << *it2 << ((std::next(it2) != cur_vec.end()) ? ", " : "\n"); } } } endsnippet snippet cout "print a variable" w cout << "$1: " << $2 << endl; endsnippet snippet random "Generate a random list" b // Generate a random sequence of length len, in range(low, high) (inclusive). // need to #include vector genRandom(int low, int high, int len){ std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution distribution(low, high); vector arr(len, 0); for (int i = 0; i != len; ++i){ arr[i] = distribution(gen); } return arr; } endsnippet snippet incset "Use set" b #include using std::set; endsnippet snippet incmap "Use map" b #include using std::map; endsnippet snippet incqueue "Use queue" b #include using std::queue; endsnippet snippet incstr "Use string" b #include using std::string; endsnippet snippet incvec "Use vector" b #include using std::vector; endsnippet snippet incstack "Use stack" b #include using std::stack; endsnippet snippet vec "std::vector" w vector<$1> ${2:vec} endsnippet snippet map "std::map" w map<$1, $2> ${3:mymap} endsnippet snippet umap "std::unordered_map" unordered_map<$1, $2> ${3:mymap} endsnippet snippet set "std::set" w set<$1> ${2:myset} endsnippet snippet uset "std::unordered_set" w unordered_set<$1> ${2:myset} endsnippet snippet queue "std::queue" w queue<$1> ${2:q} endsnippet snippet stack "std::stack" w stack<$1> ${2:mystack} endsnippet