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

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

#include "Object.h"
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

#include "debug.h"
#include <assert.h>


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

23
24
25
26
27
28
#ifndef DEFAULT_SIZE
#define DEFAULT_SIZE -1
#endif

typedef struct Vector_ {
   Object **array;
29
   Object_Compare compare;
30
31
32
33
34
35
36
37
   int arraySize;
   int growthRate;
   int items;
   char* vectorType;
   bool owner;
} Vector;


38
Vector* Vector_new(char* vectorType_, bool owner, int size, Object_Compare compare);
39
40
41

void Vector_delete(Vector* this);

42
43
#ifdef DEBUG

Hisham Muhammad's avatar
Hisham Muhammad committed
44
45
int Vector_count(Vector* this);

46
47
#endif

48
49
void Vector_prune(Vector* this);

50
51
52
53
54
55
56
57
// 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);
58

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

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

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

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

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

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

71
72
#ifdef DEBUG

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

75
76
77
78
79
80
#else

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

#endif

81
extern int Vector_size(Vector* this);
82

83
84
85
/*

*/
86
87
88

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

89
extern int Vector_indexOf(Vector* this, void* search_, Object_Compare compare);
90
91

#endif