From 3e95235db8184712c34982bfd4bbc9f89a51e117 Mon Sep 17 00:00:00 2001 From: luyanfei Date: Fri, 5 Feb 2021 08:41:33 +0800 Subject: [PATCH 1/8] cpp python snippets updated. --- UltiSnips/python.snippets | 2 +- snippets/cpp.snippets | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets index 6e7750413..5cc0ffb4a 100644 --- a/UltiSnips/python.snippets +++ b/UltiSnips/python.snippets @@ -6,7 +6,7 @@ priority -50 #! header snippet #! "#!/usr/bin/env python" b -#!/usr/bin/env python +#!/usr/bin/env python3 $0 endsnippet diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index f39d743e8..ee33c4a46 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -1,10 +1,23 @@ extends c +## Main +# main(void) +snippet cmain + #include + using namespace std; + int main() + { + ${0} + return 0; + } +## ## ## Preprocessor # #include <...> snippet incc #include <${1:iostream}> +snippet incv + #include <${1:vector}> snippet binc #include ## @@ -182,7 +195,6 @@ snippet fori for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) { ${4} } - # foreach snippet fore for (${1:auto} ${2:i} : ${3:container}) { From 2a6807aea17fe37800ab9bafa74ee90c6e6bad08 Mon Sep 17 00:00:00 2001 From: luyanfei Date: Sun, 14 Feb 2021 22:16:14 +0800 Subject: [PATCH 2/8] cpp snippets updated. --- snippets/cpp.snippets | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index ee33c4a46..6ac0c9120 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -5,8 +5,7 @@ snippet cmain #include using namespace std; - int main() - { + int main() { ${0} return 0; } @@ -28,6 +27,8 @@ snippet array # std::vector snippet vector std::vector<${1:T}> ${2}; +snippet vvi + vector> ${1}(${2:n}, vector(${3:m}, ${4:0})); # std::deque snippet deque std::deque<${1:T}> ${2}; From 9c84819062ef8135ad54f0021601a0c635f7d8ae Mon Sep 17 00:00:00 2001 From: luyanfei Date: Mon, 10 Jun 2024 13:34:59 +0800 Subject: [PATCH 3/8] cmain updated. --- snippets/cpp.snippets | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index f17fdbad9..25bc5fcc6 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -5,6 +5,12 @@ snippet cmain #include using namespace std; + int main() + { + ${0} + return 0; + } + ## Main # main() snippet mainn From f9c50260810b68746d71ced91f6fbf148c660575 Mon Sep 17 00:00:00 2001 From: luyanfei Date: Mon, 10 Jun 2024 18:36:09 +0800 Subject: [PATCH 4/8] cpp.snippet updated. --- snippets/cpp.snippets | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index 25bc5fcc6..ae033e22f 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -5,8 +5,7 @@ snippet cmain #include using namespace std; - int main() - { + int main() { ${0} return 0; } @@ -14,8 +13,7 @@ snippet cmain ## Main # main() snippet mainn - int main() - { + int main() { ${0} return 0; } From 16ab35b0b5c61adfaed64f21576542045b46b39f Mon Sep 17 00:00:00 2001 From: luyanfei Date: Wed, 26 Jun 2024 19:04:00 +0800 Subject: [PATCH 5/8] add cppmain. --- snippets/cpp.snippets | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index ae033e22f..3b1cafc93 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -1,12 +1,23 @@ extends c ## Main # main(void) -snippet cmain +snippet cppmain #include + ${0} using namespace std; int main() { - ${0} + ${1} + return 0; + } + +snippet cmain + #include + ${0} + using namespace std; + + int main() { + ${1} return 0; } From 14b9ee83cb305039d1e36c1f010958938c64b41e Mon Sep 17 00:00:00 2001 From: luyanfei Date: Thu, 8 Aug 2024 09:59:12 +0800 Subject: [PATCH 6/8] cppmain updated. --- snippets/c.snippets | 13 +++++++++++++ snippets/cpp.snippets | 10 +++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/snippets/c.snippets b/snippets/c.snippets index a3f4d5c99..c6e72842a 100644 --- a/snippets/c.snippets +++ b/snippets/c.snippets @@ -390,3 +390,16 @@ snippet asm : : ); + +snippet sd + scanf("%d", &${0:n}); +snippet s2d + scanf("%d%d", &${1:m}, &${0:n}); +snippet wsd + while (scanf("%d", &${1:n}) == 1) { + ${0} + } +snippet pdn + printf("%d\n", ${0:n}); +snippet pd + printf("%d", ${0:n}); diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index 3b1cafc93..40a7c2b6f 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -3,21 +3,21 @@ extends c # main(void) snippet cppmain #include - ${0} + ${1} using namespace std; int main() { - ${1} + ${0} return 0; } snippet cmain #include - ${0} + ${1} using namespace std; int main() { - ${1} + ${0} return 0; } @@ -33,7 +33,7 @@ snippet mainn # #include <...> snippet incc #include <${1:iostream}> -snippet incv +snippet inc #include <${1:vector}> snippet binc #include From e3639bc5933c1b45380b0b4bfb9ed1a6a17f24d1 Mon Sep 17 00:00:00 2001 From: luyanfei Date: Wed, 25 Sep 2024 11:12:36 +0800 Subject: [PATCH 7/8] add cgraph. --- snippets/cpp.snippets | 56 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index 40a7c2b6f..9c8804089 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -33,7 +33,7 @@ snippet mainn # #include <...> snippet incc #include <${1:iostream}> -snippet inc +snippet incv #include <${1:vector}> snippet binc #include @@ -300,3 +300,57 @@ snippet gtepar "GTest:add parameterized test" # GTest:instantiate parameterized test snippet gteparins "GTest:instantiate parameterized test" INSTANTIATE_TEST_SUITE_P(${1:InstantiationName}, ${2:SuiteName}, ${0}); + +snippet sedge "struct edge" + struct edge { + int to, next; + edge(int to, int next) : to(to), next(next) {} + }; + +snippet sedgew "struct edge" + struct edge { + int to, next, w; + edge(int to, int next, int w) : to(to), next(next), w(w) {} + }; + +snippet vi "vector" + vector + +snippet cgraph "class Graph" + class Edge { + public: + int to, next; + Edge(int to, int next) : to(to), next(next) {} + }; + + class Graph { + vector head; + vector edges; + public: + Graph(int n) : head(n + 1, -1) {} + void add_edge(int u, int v) { + edges.emplace_back(v, head[u]); + head[u] = edges.size() - 1; + } + ${0} + }; + +snippet cgraphw "class Graph" + class Edge { + public: + int to, next, w; + Edge(int to, int next, int w) : to(to), next(next), w(w) {} + }; + + class Graph { + vector head; + vector edges; + public: + Graph(int n) : head(n + 1, -1) {} + void add_edge(int u, int v, int w) { + edges.emplace_back(v, head[u], w); + head[u] = edges.size() - 1; + } + ${0} + }; + From 7cf1f243b4097f44aa42aabac47a299e46da8c95 Mon Sep 17 00:00:00 2001 From: luyanfei Date: Fri, 4 Oct 2024 15:35:06 +0800 Subject: [PATCH 8/8] cpp.snippets updated. --- snippets/cpp.snippets | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index 9c8804089..52fd77137 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -317,8 +317,7 @@ snippet vi "vector" vector snippet cgraph "class Graph" - class Edge { - public: + struct Edge { int to, next; Edge(int to, int next) : to(to), next(next) {} }; @@ -336,8 +335,7 @@ snippet cgraph "class Graph" }; snippet cgraphw "class Graph" - class Edge { - public: + struct Edge { int to, next, w; Edge(int to, int next, int w) : to(to), next(next), w(w) {} };