1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
snippet bare "barebone code template"
#include <iostream>
#include <vector>
#include <string>
#include <map>
#inlcude <unordered_map>
#include <set>
#inlucde <unordered_set>
#include <stack>
#include <queue>
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;
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()) ? ", " : "]\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;
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<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
|