Vector.h 1.55 KB
Newer Older
Hisham Muhammad's avatar
Hisham Muhammad committed
1
/* Do not edit this file. It was automatically generated. */
2
3
4
5

#ifndef HEADER_Vector
#define HEADER_Vector
/*
Hisham Muhammad's avatar
Hisham Muhammad committed
6
htop - Vector.h
Hisham Muhammad's avatar
Hisham Muhammad committed
7
(C) 2004-2011 Hisham H. Muhammad
8
9
10
11
12
13
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/

#include "Object.h"

14
15
#define swap(a_,x_,y_) do{ void* tmp_ = a_[x_]; a_[x_] = a_[y_]; a_[y_] = tmp_; }while(0)

16
17
18
19
20
21
#ifndef DEFAULT_SIZE
#define DEFAULT_SIZE -1
#endif

typedef struct Vector_ {
   Object **array;
22
   Object_Compare compare;
23
24
25
26
27
28
29
30
   int arraySize;
   int growthRate;
   int items;
   char* vectorType;
   bool owner;
} Vector;


31
Vector* Vector_new(char* vectorType_, bool owner, int size, Object_Compare compare);
32
33
34

void Vector_delete(Vector* this);

35
36
#ifdef DEBUG

Hisham Muhammad's avatar
Hisham Muhammad committed
37
38
int Vector_count(Vector* this);

39
40
#endif

41
42
void Vector_prune(Vector* this);

43
44
45
46
47
48
49
50
// If I were to use only one sorting algorithm for both cases, it would probably be this one:
/*

*/

void Vector_quickSort(Vector* this);

void Vector_insertionSort(Vector* this);
51

Hisham Muhammad's avatar
Hisham Muhammad committed
52
void Vector_insert(Vector* this, int idx, void* data_);
53

Hisham Muhammad's avatar
Hisham Muhammad committed
54
Object* Vector_take(Vector* this, int idx);
55

Hisham Muhammad's avatar
Hisham Muhammad committed
56
Object* Vector_remove(Vector* this, int idx);
57

Hisham Muhammad's avatar
Hisham Muhammad committed
58
void Vector_moveUp(Vector* this, int idx);
59

Hisham Muhammad's avatar
Hisham Muhammad committed
60
void Vector_moveDown(Vector* this, int idx);
61

Hisham Muhammad's avatar
Hisham Muhammad committed
62
void Vector_set(Vector* this, int idx, void* data_);
63

64
65
#ifdef DEBUG

Hisham Muhammad's avatar
Hisham Muhammad committed
66
extern Object* Vector_get(Vector* this, int idx);
67

68
69
70
71
72
73
#else

#define Vector_get(v_, idx_) ((v_)->array[idx_])

#endif

74
extern int Vector_size(Vector* this);
75

76
77
78
/*

*/
79
80
81

void Vector_add(Vector* this, void* data_);

82
extern int Vector_indexOf(Vector* this, void* search_, Object_Compare compare);
83
84

#endif