65 lines
808 B
C++
65 lines
808 B
C++
#ifndef _INC_STDIO
|
|
#include <stdio.h>
|
|
#endif
|
|
|
|
#ifndef _GLIBCXX_STDLIB_H
|
|
#include <stdlib.h>
|
|
#endif
|
|
|
|
#include <time.h>
|
|
|
|
class Vec
|
|
{
|
|
private:
|
|
int *_v;
|
|
int _len;
|
|
int _used;
|
|
bool _sorted = false;
|
|
|
|
void expand();
|
|
|
|
void shrink();
|
|
|
|
public:
|
|
~Vec()
|
|
{
|
|
delete[] _v;
|
|
delete &_len;
|
|
delete &_used;
|
|
delete &_sorted;
|
|
}
|
|
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);
|
|
|
|
void reorder();
|
|
|
|
private:
|
|
void merge(int lo, int mi, int hi);
|
|
};
|