aboutsummaryrefslogtreecommitdiff
path: root/my_snippets/cpp.snippets
diff options
context:
space:
mode:
authorMichal Hanus <hanus.michal@divelit.cz>2024-03-02 18:49:55 +0100
committerMichal Hanus <hanus.michal@divelit.cz>2024-03-02 18:49:55 +0100
commitaab38f32e0a02e43565a554d0a76ff65636499b8 (patch)
treef3f00df05c63228c69a338e80fd0e7d02986e8cf /my_snippets/cpp.snippets
parent99353a355321d68ef4fb3c26291084b23e8f4978 (diff)
crazyshitHEADmaster
Diffstat (limited to 'my_snippets/cpp.snippets')
-rw-r--r--my_snippets/cpp.snippets187
1 files changed, 0 insertions, 187 deletions
diff --git a/my_snippets/cpp.snippets b/my_snippets/cpp.snippets
deleted file mode 100644
index 148c8d0..0000000
--- a/my_snippets/cpp.snippets
+++ /dev/null
@@ -1,187 +0,0 @@
-snippet bare "barebone code template"
-#include <iostream>
-#include <vector>
-#include <string>
-#include <map>
-#include <unordered_map>
-#include <set>
-#include <unordered_set>
-#include <stack>
-#include <queue>
-#include <numeric>
-
-using std::cout;
-using std::endl;
-using std::vector;
-using std::string;
-using std::map;
-using std::unordered_map;
-using std::set;
-using std::unordered_set;
-using std::stack;
-using std::queue;
-using std::pair;
-using std::make_pair;
-
-
-
-int main()
-{
-
- return 0;
-}
-endsnippet
-
-snippet icd "#include directive" b
-#include <$1>
-$0
-endsnippet
-
-snippet plist "print vector" w
-template <class T>
-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()) ? ", " : "");
- }
- std::cout << "]\n";
-}
-endsnippet
-
-snippet pmat "print list of list" w
-template <class T>
-void printMat(const vector<vector<T>>& mat, const string& desc){
- cout << desc << ": " << endl;
-
- for (auto it1 = mat.begin(); it1 != mat.end(); it1++){
- auto cur_vec = *it1;
- cout << "[";
- for (auto it2 = cur_vec.begin(); it2 != cur_vec.end(); it2++){
- cout << *it2 << ((std::next(it2) != cur_vec.end()) ? ", " : "]\n");
- }
- }
-}
-endsnippet
-
-snippet pqueue "print queue"
-template <class T>
-void printQueue(T q){
- while(!q.empty()){
- std::cout << q.top() << " ";
- q.pop();
- }
- std::cout << '\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<random>
-vector<int> genRandom(int low, int high, int len){
- std::random_device rd;
- std::mt19937 gen(rd());
- std::uniform_int_distribution<int> distribution(low, high);
-
- vector<int> arr(len, 0);
- for (int i = 0; i != len; ++i){
- arr[i] = distribution(gen);
- }
-
- return arr;
-}
-endsnippet
-
-snippet incset "Use set" b
-#include <set>
-
-using std::set;
-endsnippet
-
-snippet incmap "Use map" b
-#include <map>
-
-using std::map;
-endsnippet
-
-snippet incqueue "Use queue" b
-#include <queue>
-
-using std::queue;
-endsnippet
-
-snippet incstr "Use string" b
-#include <string>
-
-using std::string;
-endsnippet
-
-snippet incvec "Use vector" b
-#include <vector>
-
-using std::vector;
-endsnippet
-
-snippet incstack "Use stack" b
-#include <stack>
-
-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
-
-snippet sol "solution" w
-auto solution = Solution();
-$0
-endsnippet
-
-snippet for "for loop" w
-for ($1; $2; $3){
- $4
-}
-endsnippet
-
-snippet if "if condition" w
-if ($1){
- $2
-}
-$0
-endsnippet
-
-snippet ifelse "if else condition"
-if ($1){
- $2
-}else{
-
-}
-endsnippet