diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e6b77ad --- /dev/null +++ b/.vscode/launch.json @@ -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 + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4626d77 --- /dev/null +++ b/.vscode/settings.json @@ -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" + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..1803238 --- /dev/null +++ b/.vscode/tasks.json @@ -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" + } + ] +} \ No newline at end of file diff --git a/src/heap.h b/src/heap.h index 8126322..1827a7b 100644 --- a/src/heap.h +++ b/src/heap.h @@ -2,13 +2,15 @@ #include using namespace std; + + template class Heap { public: - typedef int (*Compare)(T& , T& ); + typedef int (*Compare)(T , T); -private: +private: std::vector data; Compare compare; @@ -48,4 +50,9 @@ public: this->data[cur_idx] = value; } + + + T pop() { + + } }; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 4e4af3b..fb2f4a0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,19 @@ #include #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 h ; + Heap h(IntCompare); + h.push(3); h.push(5); h.push(2);