Vector.h 1.5 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
   ObjectClass* type;
23
24
25
26
27
28
29
   int arraySize;
   int growthRate;
   int items;
   bool owner;
} Vector;


30
Vector* Vector_new(ObjectClass* type, bool owner, int size);
31
32
33

void Vector_delete(Vector* this);

34
35
#ifdef DEBUG

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

38
39
#endif

40
41
void Vector_prune(Vector* this);

42
43
44
45
46
47
48
49
// 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);
50

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

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

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

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

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

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

63
64
#ifdef DEBUG

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

67
68
69
70
71
72
#else

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

#endif

73
extern int Vector_size(Vector* this);
74

75
76
77
/*

*/
78
79
80

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

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

#endif