From c00d21929f53e74a2d53d3c6092ddd31d7466e68 Mon Sep 17 00:00:00 2001 From: iridiumR Date: Fri, 22 Oct 2021 00:14:06 +0800 Subject: [PATCH] 5 --- ex5/vec.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 ex5/vec.h diff --git a/ex5/vec.h b/ex5/vec.h new file mode 100644 index 0000000..a03dde2 --- /dev/null +++ b/ex5/vec.h @@ -0,0 +1,56 @@ +#ifndef _INC_STDIO +#include +#endif + +#ifndef _GLIBCXX_STDLIB_H +#include +#endif + +#include + +class Vec +{ +private: + int *_v; + int _len; + int _used; + bool _sorted = false; + + void expand(); + + void shrink(); + +public: + Vec(int _len,int mode); + + int get(int a); + + int search(int value); + + void put(int a, int value); + + void swap(int a, int b); + + int insert(int locate, int value); + + int remove(int locate, int value); + + int remove_sorted(int value); + + int find(int value); + + void bubbleSort(); + + void printall(); + + int getlen(); + + int getused(); + + int count(int value); + + void mergeSort(int lo, int hi); + +private: + void merge(int lo, int mi, int hi); +};