添加vscode 文件
This commit is contained in:
parent
df39f85c8c
commit
4275ca52b3
28
.vscode/launch.json
vendored
Normal file
28
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "(gdb) Launch",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/bin/main",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"preLaunchTask": "make",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty-printing for gdb",
|
||||
"text": "-enable-pretty-printing",
|
||||
"ignoreFailures": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
36
.vscode/settings.json
vendored
Normal file
36
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"files.associations": {
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"array": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"fstream": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"new": "cpp",
|
||||
"optional": "cpp",
|
||||
"ostream": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"tuple": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"utility": "cpp"
|
||||
}
|
||||
}
|
12
.vscode/tasks.json
vendored
Normal file
12
.vscode/tasks.json
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "make",
|
||||
"type": "shell",
|
||||
"command": "make"
|
||||
}
|
||||
]
|
||||
}
|
11
src/heap.h
11
src/heap.h
|
@ -2,13 +2,15 @@
|
|||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
class Heap
|
||||
{
|
||||
public:
|
||||
typedef int (*Compare)(T& , T& );
|
||||
typedef int (*Compare)(T , T);
|
||||
|
||||
private:
|
||||
private:
|
||||
std::vector<T> data;
|
||||
Compare compare;
|
||||
|
||||
|
@ -48,4 +50,9 @@ public:
|
|||
|
||||
this->data[cur_idx] = value;
|
||||
}
|
||||
|
||||
|
||||
T pop() {
|
||||
|
||||
}
|
||||
};
|
13
src/main.cpp
13
src/main.cpp
|
@ -1,8 +1,19 @@
|
|||
#include <iostream>
|
||||
#include "heap.h"
|
||||
|
||||
int IntCompare(int v1, int v2) {
|
||||
if(v1 > v2) {
|
||||
return 1;
|
||||
} else if (v1 < v2){
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
Heap<int> h ;
|
||||
Heap<int> h(IntCompare);
|
||||
|
||||
h.push(3);
|
||||
h.push(5);
|
||||
h.push(2);
|
||||
|
|
Loading…
Reference in New Issue
Block a user