Datasets:
upload whole little cpp dataset
Browse files
cpp_dataset/README.md
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
task_categories:
|
4 |
+
- text-generation
|
5 |
+
- fill-mask
|
6 |
+
language:
|
7 |
+
- code
|
8 |
+
size_categories:
|
9 |
+
- 1K<n<10K
|
10 |
+
dataset_info:
|
11 |
+
- config_name: all
|
12 |
+
features:
|
13 |
+
- name: repository_name
|
14 |
+
dtype: string
|
15 |
+
- name: func_path_in_repository
|
16 |
+
dtype: string
|
17 |
+
- name: func_name
|
18 |
+
dtype: string
|
19 |
+
- name: whole_func_string
|
20 |
+
dtype: string
|
21 |
+
- name: language
|
22 |
+
dtype: string
|
23 |
+
- name: func_code_string
|
24 |
+
dtype: string
|
25 |
+
- name: func_code_tokens
|
26 |
+
sequence: string
|
27 |
+
- name: func_documentation_string
|
28 |
+
dtype: string
|
29 |
+
- name: func_documentation_tokens
|
30 |
+
sequence: string
|
31 |
+
- name: split_name
|
32 |
+
dtype: string
|
33 |
+
- name: func_code_url
|
34 |
+
dtype: string
|
35 |
+
splits:
|
36 |
+
- name: train
|
37 |
+
num_bytes: 5850604083
|
38 |
+
num_examples: 1880853
|
39 |
+
- name: test
|
40 |
+
num_bytes: 308626333
|
41 |
+
num_examples: 100529
|
42 |
+
- name: validation
|
43 |
+
num_bytes: 274564382
|
44 |
+
num_examples: 89154
|
45 |
+
download_size: 5117370511
|
46 |
+
dataset_size: 6433794798
|
47 |
+
- config_name: cpp
|
48 |
+
features:
|
49 |
+
- name: repository_name
|
50 |
+
dtype: string
|
51 |
+
- name: func_path_in_repository
|
52 |
+
dtype: string
|
53 |
+
- name: func_name
|
54 |
+
dtype: string
|
55 |
+
- name: whole_func_string
|
56 |
+
dtype: string
|
57 |
+
- name: language
|
58 |
+
dtype: string
|
59 |
+
- name: func_code_string
|
60 |
+
dtype: string
|
61 |
+
- name: func_code_tokens
|
62 |
+
sequence: string
|
63 |
+
- name: func_documentation_string
|
64 |
+
dtype: string
|
65 |
+
- name: func_documentation_tokens
|
66 |
+
sequence: string
|
67 |
+
- name: split_name
|
68 |
+
dtype: string
|
69 |
+
- name: func_code_url
|
70 |
+
dtype: string
|
71 |
+
splits:
|
72 |
+
- name: train
|
73 |
+
num_bytes: 1429272535
|
74 |
+
num_examples: 454451
|
75 |
+
- name: test
|
76 |
+
num_bytes: 82377246
|
77 |
+
num_examples: 26909
|
78 |
+
- name: validation
|
79 |
+
num_bytes: 42358315
|
80 |
+
num_examples: 15328
|
81 |
+
download_size: 1060569153
|
82 |
+
dataset_size: 1554008096
|
83 |
+
configs:
|
84 |
+
- config_name: default
|
85 |
+
data_files:
|
86 |
+
- split: train
|
87 |
+
path: "train/train.jsonl"
|
88 |
+
- split: test
|
89 |
+
path: "test/test.jsonl"
|
90 |
+
- split: validation
|
91 |
+
path: "validation/validation.jsonl"
|
92 |
+
---
|
93 |
+
|
94 |
+
# C++ Dataset
|
95 |
+
> documentation source: https://huggingface.co/docs/datasets/main/en/repository_structure
|
96 |
+
|
97 |
+
|
98 |
+
|
99 |
+
### Supported Tasks and Leaderboards
|
100 |
+
|
101 |
+
- `language-modeling`: The dataset can be used to train a model for modelling programming languages, which consists in building language models for programming languages.
|
102 |
+
|
103 |
+
### Language
|
104 |
+
|
105 |
+
- C++ **programming** language
|
106 |
+
|
107 |
+
|
108 |
+
|
109 |
+
|
110 |
+
## Dataset Structure
|
111 |
+
|
112 |
+
### Data Instances
|
113 |
+
|
114 |
+
A data point consists of a function code along with its documentation. Each data point also contains meta data on the function, such as the repository it was extracted from.
|
115 |
+
```
|
116 |
+
{
|
117 |
+
'id': '0',
|
118 |
+
'repository_name': 'organisation/repository',
|
119 |
+
'func_path_in_repository': 'src/path/to/file.py',
|
120 |
+
'func_name': 'func',
|
121 |
+
'whole_func_string': 'def func(args):\n"""Docstring"""\n [...]',
|
122 |
+
'language': 'python',
|
123 |
+
'func_code_string': '[...]',
|
124 |
+
'func_code_tokens': ['def', 'func', '(', 'args', ')', ...],
|
125 |
+
'func_documentation_string': 'Docstring',
|
126 |
+
'func_documentation_string_tokens': ['Docstring'],
|
127 |
+
'split_name': 'train',
|
128 |
+
'func_code_url': 'https://github.com/<org>/<repo>/blob/<hash>/src/path/to/file.py#L111-L150'
|
129 |
+
}
|
130 |
+
```
|
131 |
+
|
132 |
+
### Data Fields
|
133 |
+
|
134 |
+
- `id`: Arbitrary number
|
135 |
+
- `repository_name`: name of the GitHub repository
|
136 |
+
- `func_path_in_repository`: tl;dr: path to the file which holds the function in the repository
|
137 |
+
- `func_name`: name of the function in the file
|
138 |
+
- `whole_func_string`: Code + documentation of the function
|
139 |
+
- `language`: Programming language in whoch the function is written
|
140 |
+
- `func_code_string`: Function code
|
141 |
+
- `func_code_tokens`: Tokens yielded by Treesitter
|
142 |
+
- `func_documentation_string`: Function documentation
|
143 |
+
- `func_documentation_string_tokens`: Tokens yielded by Treesitter
|
144 |
+
- `split_name`: Name of the split to which the example belongs (one of train, test or valid)
|
145 |
+
- `func_code_url`: URL to the function code on Github
|
146 |
+
|
147 |
+
### Data Splits
|
148 |
+
|
149 |
+
Three splits are available:
|
150 |
+
- train
|
151 |
+
- test
|
152 |
+
- valid
|
153 |
+
|
154 |
+
### Citation Information
|
155 |
+
|
156 |
+
- based on (format and idea): https://huggingface.co/datasets/code_search_net/blob/main/code_search_net.py
|
157 |
+
|
158 |
+
@article{husain2019codesearchnet,
|
159 |
+
title={C++ Dataset},
|
160 |
+
author={Klaes, Malte},
|
161 |
+
year={2024}
|
162 |
+
}
|
cpp_dataset/test/numberGuessing.cpp
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <iostream>
|
2 |
+
#include <cstdlib>
|
3 |
+
#include <ctime>
|
4 |
+
|
5 |
+
using namespace std;
|
6 |
+
|
7 |
+
class NumberGame {
|
8 |
+
private:
|
9 |
+
int secretNumber;
|
10 |
+
|
11 |
+
public:
|
12 |
+
NumberGame() {
|
13 |
+
srand(time(0));
|
14 |
+
secretNumber = rand() % 11;
|
15 |
+
}
|
16 |
+
|
17 |
+
int guessNumber() {
|
18 |
+
int guess;
|
19 |
+
cout << "Rate eine Zahl zwischen 0 und 10: ";
|
20 |
+
cin >> guess;
|
21 |
+
return guess;
|
22 |
+
}
|
23 |
+
|
24 |
+
|
25 |
+
bool checkGuess(int guess) {
|
26 |
+
if (guess == secretNumber) {
|
27 |
+
cout << "Glückwunsch! Du hast die richtige Zahl erraten." << endl;
|
28 |
+
return true;
|
29 |
+
} else if (guess < secretNumber) {
|
30 |
+
cout << "Die gesuchte Zahl ist größer als deine Eingabe." << endl;
|
31 |
+
} else {
|
32 |
+
cout << "Die gesuchte Zahl ist kleiner als deine Eingabe." << endl;
|
33 |
+
}
|
34 |
+
return false;
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
void startGame() {
|
39 |
+
int attempts = 0;
|
40 |
+
bool correctGuess = false;
|
41 |
+
cout << "Willkommen beim Zahlenspiel!" << endl;
|
42 |
+
while (!correctGuess && attempts < 3) {
|
43 |
+
int guess = guessNumber();
|
44 |
+
correctGuess = checkGuess(guess);
|
45 |
+
attempts++;
|
46 |
+
}
|
47 |
+
if (!correctGuess) {
|
48 |
+
cout << "Du hast alle Versuche aufgebraucht. Die gesuchte Zahl war: " << secretNumber << endl;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
};
|
52 |
+
|
53 |
+
int main() {
|
54 |
+
NumberGame game;
|
55 |
+
game.startGame();
|
56 |
+
return 0;
|
57 |
+
}
|
cpp_dataset/test/test.jsonl
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"repo": "ownRepo", "path": "cppExample.cpp", "func_name": "#include<iostream>", "original_string": "#include<iostream>", "code_tokens": ["#include<iostream>"], "docstring_tokens": [], "sha": "random_sha", "url": "noURL", "partition": "test"}
|
2 |
+
{"repo": "ownRepo", "path": "cppExample.cpp", "func_name": "NumberGame()", "original_string": "NumberGame() {\n srand(time(0));\n secretNumber = rand() % 11;\n }", "code_tokens": ["NumberGame", "(", ")", "{", "srand", "(", "time", "(", "0", ")", ")", ";", "secretNumber", "=", "rand", "(", ")", "%", "11", ";", "}"], "docstring_tokens": [], "sha": "random_sha", "url": "noURL", "partition": "test"}
|
3 |
+
{"repo": "ownRepo", "path": "cppExample.cpp", "func_name": "guessNumber()", "original_string": "int guessNumber() {\n int guess;\n cout << \"Rate eine Zahl zwischen 0 und 10: \";\n cin >> guess;\n return guess;\n }", "code_tokens": ["int", "guessNumber", "(", ")", "{", "int", "guess", ";", "cout", "<<", "\"Rate eine Zahl zwischen 0 und 10: \"", ";", "cin", ">>", "guess", ";", "return", "guess", ";", "}"], "docstring_tokens": [], "sha": "random_sha", "url": "noURL", "partition": "test"}
|
4 |
+
{"repo": "ownRepo", "path": "cppExample.cpp", "func_name": "checkGuess(int guess)", "original_string": "bool checkGuess(int guess) {\n if (guess == secretNumber) {\n cout << \"Glückwunsch! Du hast die richtige Zahl erraten.\" << endl;\n return true;\n } else if (guess < secretNumber) {\n cout << \"Die gesuchte Zahl ist größer als deine Eingabe.\" << endl;\n } else {\n cout << \"Die gesuchte Zahl ist kleiner als deine Eingabe.\" << endl;\n }\n return false;\n }", "code_tokens": ["bool", "checkGuess", "(", "int", "guess", ")", "{", "if", "(", "guess", "==", "secretNumber", ")", "{", "cout", "<<", "\"Glückwunsch! Du hast die richtige Zahl erraten.\"", "<<", "endl", ";", "return", "true", ";", "}", "else", "if", "(", "guess", "<", "secretNumber", ")", "{", "cout", "<<", "\"Die gesuchte Zahl ist größer als deine Eingabe.\"", "<<", "endl", ";", "}", "else", "{", "cout", "<<", "\"Die gesuchte Zahl ist kleiner als deine Eingabe.\"", "<<", "endl", ";", "}", "return", "false", ";", "}"], "docstring_tokens": [], "sha": "random_sha", "url": "noURL", "partition": "test"}
|
5 |
+
{"repo": "ownRepo", "path": "cppExample.cpp", "func_name": "startGame()", "original_string": "void startGame() {\n int attempts = 0;\n bool correctGuess = false; \n cout << \"Willkommen beim Zahlenspiel!\" << endl; \n while (!correctGuess && attempts < 3) {\n int guess = guessNumber();\n correctGuess = checkGuess(guess);\n attempts++;\n }\n if (!correctGuess) {\n cout << \"Du hast alle Versuche aufgebraucht. Die gesuchte Zahl war: \" << secretNumber << endl;\n }\n }", "code_tokens": ["void", "startGame", "(", ")", "{", "int", "attempts", "=", "0", ";", "bool", "correctGuess", "=", "false", ";", "cout", "<<", "\"Willkommen beim Zahlenspiel!\"", "<<", "endl", ";", "while", "(", "!", "correctGuess", "&&", "attempts", "<", "3", ")", "{", "int", "guess", "=", "guessNumber", "(", ")", ";", "correctGuess", "=", "checkGuess", "(", "guess", ")", ";", "attempts", "+", "+", ";", "}", "if", "(", "!", "correctGuess", ")", "{", "cout", "<<", "\"Du hast alle Versuche aufgebraucht. Die gesuchte Zahl war: \"", "<<", "secretNumber", "<<", "endl", ";", "}", "}"], "docstring_tokens": [], "sha": "random_sha", "url": "noURL", "partition": "test"}
|
6 |
+
{"repo": "ownRepo", "path": "cppExample.cpp", "func_name": "main()", "original_string": "int main() {\n NumberGame game;\n game.startGame();\n return 0;\n}", "code_tokens": ["int", "main", "(", ")", "{", "NumberGame", "game", ";", "game", ".", "startGame", "(", ")", ";", "return", "0", ";", "}"], "docstring_tokens": [], "sha": "random_sha", "url": "noURL", "partition": "test"}
|
cpp_dataset/train/calculation.cpp
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include <iostream>
|
2 |
+
|
3 |
+
// Funktion für Addition
|
4 |
+
int addition(int a, int b) {
|
5 |
+
return a + b;
|
6 |
+
}
|
7 |
+
|
8 |
+
// Funktion für Subtraktion
|
9 |
+
int subtraction(int a, int b) {
|
10 |
+
return a - b;
|
11 |
+
}
|
12 |
+
|
13 |
+
// Funktion für Multiplikation
|
14 |
+
int multiplication(int a, int b) {
|
15 |
+
return a * b;
|
16 |
+
}
|
17 |
+
|
18 |
+
// Funktion für Division
|
19 |
+
float division(int a, int b) {
|
20 |
+
if (b == 0) {
|
21 |
+
std::cerr << "Fehler: Division durch Null!" << std::endl;
|
22 |
+
return 0; // Oder eine geeignete Fehlerbehandlung
|
23 |
+
}
|
24 |
+
return static_cast<float>(a) / b;
|
25 |
+
}
|
26 |
+
|
27 |
+
int main() {
|
28 |
+
int x = 10;
|
29 |
+
int y = 5;
|
30 |
+
|
31 |
+
// Aufrufen der Funktionen und Ausgabe der Ergebnisse
|
32 |
+
std::cout << "Addition: " << addition(x, y) << std::endl;
|
33 |
+
std::cout << "Subtraktion: " << subtraction(x, y) << std::endl;
|
34 |
+
std::cout << "Multiplikation: " << multiplication(x, y) << std::endl;
|
35 |
+
std::cout << "Division: " << division(x, y) << std::endl;
|
36 |
+
|
37 |
+
return 0;
|
38 |
+
}
|
cpp_dataset/train/train.jsonl
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{"repo": "ownRepo", "path": "cppExample.cpp", "func_name": "include", "original_string": "#include <iostream>\n", "code_tokens":["#include", "<iostream>"], "docstring_tokens": [], "sha": "[random sha]", "url": "noURL", "partition": "train"}
|
2 |
+
{"repo": "ownRepo", "path": "cppExample.cpp", "func_name": "addition", "original_string": "int addition(int a, int b) {\n return a + b;\n}\n", "code_tokens":["int", "addition", "(", "int", "a", ",", "int", "b", ")", "{", "return", "a", "+", "b", ";", "}"], "docstring_tokens": [], "sha": "[random sha]", "url": "noURL", "partition": "train"}
|
3 |
+
{"repo": "ownRepo", "path": "cppExample.cpp", "func_name": "subtraction", "original_string": "int subtraction(int a, int b) {\n return a - b;\n}\n", "code_tokens":["int", "subtraction", "(", "int", "a", ",", "int", "b", ")", "{", "return", "a", "-", "b", ";", "}"], "docstring_tokens": [], "sha": "[random sha]", "url": "noURL", "partition": "train"}
|
4 |
+
{"repo": "ownRepo", "path": "cppExample.cpp", "func_name": "multiplication", "original_string": "int multiplication(int a, int b) {\n return a * b;\n}\n", "code_tokens":["int", "multiplication", "(", "int", "a", ",", "int", "b", ")", "{", "return", "a", "*", "b", ";", "}"], "docstring_tokens": [], "sha": "[random sha]", "url": "noURL", "partition": "train"}
|
5 |
+
{"repo": "ownRepo", "path": "cppExample.cpp", "func_name": "division", "original_string": "float division(int a, int b) {\n if (b == 0) {\n std::cerr << \"Fehler: Division durch Null!\" << std::endl;\n return 0; // Oder eine geeignete Fehlerbehandlung\n }\n return static_cast<float>(a) / b;\n}\n", "code_tokens":["float", "division", "(", "int", "a", ",", "int", "b", ")", "{", "if", "(", "b", "==", "0", ")", "{", "std", "::", "cerr", "<<", "\"Fehler", ":", "Division", "durch", "Null", "!", "\"", "<<", "std", "::", "endl", ";", "return", "0", ";", "}", "return", "static_cast<float>", "(", "a", ")", "/", "b", ";", "}"], "docstring_tokens": [], "sha": "[random sha]", "url": "noURL", "partition": "train"}
|
6 |
+
{"repo": "ownRepo", "path": "cppExample.cpp", "func_name": "main", "original_string": "int main() {\n int x = 10;\n int y = 5;\n\n // Aufrufen der Funktionen und Ausgabe der Ergebnisse\n std::cout << \"Addition: \" << addition(x, y) << std::endl;\n std::cout << \"Subtraktion: \" << subtraction(x, y) << std::endl;\n std::cout << \"Multiplikation: \" << multiplication(x, y) << std::endl;\n std::cout << \"Division: \" << division(x, y) << std::endl;\n\n return 0;\n}\n", "code_tokens":["int", "main", "(", ")", "{", "int", "x", "=", "10", ";", "int", "y", "=", "5", ";", "std", "::", "cout", "<<", "\"Addition", ":", "\"", "<<", "addition", "(", "x", ",", "y", ")", "<<", "std", "::", "endl", ";", "std", "::", "cout", "<<", "\"Subtraktion", ":", "\"", "<<", "subtraction", "(", "x", ",", "y", ")", "<<", "std", "::", "endl", ";", "std", "::", "cout", "<<", "\"Multiplikation", ":", "\"", "<<", "multiplication", "(", "x", ",", "y", ")", "<<", "std", "::", "endl", ";", "std", "::", "cout", "<<", "\"Division", ":", "\"", "<<", "division", "(", "x", ",", "y", ")", "<<", "std", "::", "endl", ";", "return", "0", ";", "}"], "docstring_tokens": [], "sha": "[random sha]", "url": "noURL", "partition": "train"}
|
cpp_dataset/validation/test.cpp
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#include<iostream>
|
2 |
+
#include<stack>
|
3 |
+
#include<vector>
|
4 |
+
#include<algorithm>
|
5 |
+
|
6 |
+
|
7 |
+
using namespace std;
|
8 |
+
|
9 |
+
int main(){
|
10 |
+
stack<int> st;
|
11 |
+
st.push(2);
|
12 |
+
st.push(4);
|
13 |
+
st.push(5);
|
14 |
+
st.push(6);
|
15 |
+
st.push(3);
|
16 |
+
st.push(4);
|
17 |
+
//for(auto elem:st) cout << elem << endl;
|
18 |
+
int count = st.size();
|
19 |
+
for (size_t i = 0; i < count; i++)
|
20 |
+
{
|
21 |
+
cout << st.top() << endl;
|
22 |
+
st.pop();
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
|
27 |
+
vector<int> v1 {5,4,3,21,5,6,8};
|
28 |
+
cout << "v1 unsorted: " << endl;
|
29 |
+
for(auto elem:v1) cout << elem << " ";
|
30 |
+
cout << endl;
|
31 |
+
|
32 |
+
sort(v1.begin(), v1.end(), [&](int a, int b){return a > b;});
|
33 |
+
cout << "v1 sorted: " << endl;
|
34 |
+
for(auto elem:v1) cout << elem << " ";
|
35 |
+
cout << endl;
|
36 |
+
|
37 |
+
vector<int> v2;
|
38 |
+
copy_if(v1.begin(), v1.end(), back_inserter(v2), [&](int a) {return a!=5;});
|
39 |
+
cout << "v2" << endl;
|
40 |
+
for(auto elem:v2) cout << elem << " ";
|
41 |
+
cout << endl;
|
42 |
+
|
43 |
+
vector<int> v3;
|
44 |
+
copy(v2.begin(), v2.end(), back_inserter(v3));
|
45 |
+
reverse(v3.begin(), v3.end());
|
46 |
+
cout << "v3" << endl;
|
47 |
+
for(auto elem:v3) cout << elem << " ";
|
48 |
+
cout << endl;
|
49 |
+
|
50 |
+
|
51 |
+
}
|
cpp_dataset/validation/validation.jsonl
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
{"repo": "ownRepo", "path": "cppExample.cpp", "func_name": "#include<iostream>", "original_string": "#include<iostream>", "code_tokens": ["#include<iostream>"], "docstring_tokens": [], "sha": "random_sha", "url": "noURL", "partition": "validation"}
|
2 |
+
{"repo": "ownRepo", "path": "cppExample.cpp", "func_name": "main()", "original_string": "int main(){\n stack<int> st;\n st.push(2);\n st.push(4);\n st.push(5);\n st.push(6);\n st.push(3);\n st.push(4);\n //for(auto elem:st) cout << elem << endl;\n int count = st.size();\n for (size_t i = 0; i < count; i++)\n {\n cout << st.top() << endl;\n st.pop();\n }\n\n\n\n vector<int> v1 {5,4,3,21,5,6,8};\n cout << \"v1 unsorted: \" << endl;\n for(auto elem:v1) cout << elem << \" \";\n cout << endl;\n\n sort(v1.begin(), v1.end(), [&](int a, int b){return a > b;});\n cout << \"v1 sorted: \" << endl;\n for(auto elem:v1) cout << elem << \" \";\n cout << endl;\n\n vector<int> v2;\n copy_if(v1.begin(), v1.end(), back_inserter(v2), [&](int a) {return a!=5;});\n cout << \"v2\" << endl;\n for(auto elem:v2) cout << elem << \" \";\n cout << endl;\n\n vector<int> v3;\n copy(v2.begin(), v2.end(), back_inserter(v3));\n reverse(v3.begin(), v3.end());\n cout << \"v3\" << endl;\n for(auto elem:v3) cout << elem << \" \";\n cout << endl;\n\n \n}", "code_tokens": ["int", "main", "(", ")", "{", "stack", "<", "int", ">", "st", ";", "st", ".", "push", "(", "2", ")", ";", "st", ".", "push", "(", "4", ")", ";", "st", ".", "push", "(", "5", ")", ";", "st", ".", "push", "(", "6", ")", ";", "st", ".", "push", "(", "3", ")", ";", "st", ".", "push", "(", "4", ")", ";", "//", "for", "(", "auto", "elem", ":", "st", ")", "cout", "<<", "elem", "<<", "endl", ";", "int", "count", "=", "st", ".", "size", "(", ")", ";", "for", "(", "size_t", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "cout", "<<", "st", ".", "top", "(", ")", "<<", "endl", ";", "st", ".", "pop", "(", ")", ";", "}", "vector", "<", "int", ">", "v1", "{", "5", ",", "4", ",", "3", ",", "21", ",", "5", ",", "6", ",", "8", "}", ";", "cout", "<<", "\"v1", "unsorted:", "\"", "<<", "endl", ";", "for", "(", "auto", "elem", ":", "v1", ")", "cout", "<<", "elem", "<<", "\"", " ", "\"", ";", "cout", "<<", "endl", ";", "sort", "(", "v1", ".", "begin", "(", ")", ",", "v1", ".", "end", "(", ")", ",", "&", "]", "(", "int", "a", ",", "int", "b", ")", "{", "return", "a", ">", "b", ";", "}", ")", ";", "cout", "<<", "\"v1", "sorted:", "\"", "<<", "endl", ";", "for", "(", "auto", "elem", ":", "v1", ")", "cout", "<<", "elem", "<<", "\"", " ", "\"", ";", "cout", "<<", "endl", ";", "vector", "<", "int", ">", "v2", ";", "copy_if", "(", "v1", ".", "begin", "(", ")", ",", "v1", ".", "end", "(", ")", ",", "back_inserter", "(", "v2", ")", ",", "&", "]", "(", "int", "a", ")", "{", "return", "a", "!=", "5", ";", "}", ")", ";", "cout", "<<", "\"v2\"", "<<", "endl", ";", "for", "(", "auto", "elem", ":", "v2", ")", "cout", "<<", "elem", "<<", "\"", " ", "\"", ";", "cout", "<<", "endl", ";", "vector", "<", "int", ">", "v3", ";", "copy", "(", "v2", ".", "begin", "(", ")", ",", "v2", ".", "end", "(", ")", ",", "back_inserter", "(", "v3", ")", ")", ";", "reverse", "(", "v3", ".", "begin", "(", ")", ",", "v3", ".", "end", "(", ")", ")", ";", "cout", "<<", "\"v3\"", "<<", "endl", ";", "for", "(", "auto", "elem", ":", "v3", ")", "cout", "<<", "elem", "<<", "\"", " ", "\"", ";", "cout", "<<", "endl", ";", "}"], "docstring_tokens": [], "sha": "random_sha", "url": "noURL", "partition": "validation"}
|