-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdataframe.h
101 lines (71 loc) · 2.28 KB
/
dataframe.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
HIGH-LEVEL-C (HLCio) // pronounced : etch-EL-Cio
THIS LIB IS FOR A LARGE SCOPE REASON, WHICH CONSISTS OF DATA MANUPILATION IN A LOW-LEVEL LANGUAGE LIKE 'C'
DATAFRAMES ARE A GOOD WAY FOR CRUD OPERATIONS ON A DATASET AS WELL AS MORE COMPLEX/ADVANCED QUERIES.
MOHAEMD-HMINI
*/
// this lib is based on dataframes as a datastructure to better control and manipulate data/!
#include<stdbool.h>
#ifndef DATAFRAME_H
#define DATAFRAME_H
#define randint(min, max) ((rand() % (int)(((max) + 1) - (min))) + (min))
// everything below is considered a container except of DF_NODE(Str, Int and Double) attributes!
struct Array;
typedef enum DF_ELEMENT_TYPE {
DF_ELEMENT_TStr,
DF_ELEMENT_TInt,
DF_ELEMENT_TDouble,
DF_ELEMENT_TNaN,
DF_ELEMENT_TArray
} DF_ELEMENT_TYPE;
// the actual element :
typedef union DF_NODE{
char* Str;
int Int;
double Double;
struct Array *Arr;
} DF_NODE;
typedef struct DF_ELEMENT{
DF_ELEMENT_TYPE type;
DF_NODE node;
}DF_ELEMENT;
// plays the role of the element's value holder :
typedef DF_ELEMENT* DF_ELEMENT_CONTAINER;
// plays the role of an array :
typedef DF_ELEMENT_CONTAINER* DF_DATA_CONTAINER;
typedef struct Array{
int size;
DF_ELEMENT_CONTAINER data;
}Array;
typedef struct DATAFRAME{
int len_rows;
int len_cols;
DF_ELEMENT_TYPE type;
DF_DATA_CONTAINER data;
}DATAFRAME;
typedef struct CMP_RESULT{
DF_ELEMENT best;
int index;
}CMP_RESULT;
DATAFRAME *Dataframe(int,int , DF_DATA_CONTAINER );
void df_free(DATAFRAME *, int);
DF_ELEMENT* df_element_create();
DF_ELEMENT arrcreate(int);
DF_ELEMENT arrinit(int, DF_ELEMENT);
void arrpush(DF_ELEMENT*, DF_ELEMENT);
void arrfree(DF_ELEMENT*);
void arrpop(DF_ELEMENT*);
void arrshow(DF_ELEMENT*);
CMP_RESULT arrcmp(DF_ELEMENT*, CMP_RESULT (*)());
bool arrequal(DF_ELEMENT*, DF_ELEMENT*);
DF_ELEMENT df_element_copy(DF_ELEMENT);
DATAFRAME *df_full(int, int ,DF_ELEMENT_TYPE ,DF_ELEMENT);
void df_remove_column(DATAFRAME *, int);
void df_remove_row(DATAFRAME *, int);
void DF_STR_TO_INT(DF_ELEMENT*);
void DF_INT_TO_STR(DF_ELEMENT*);
void df_map(DATAFRAME *,void (*fun)(DF_ELEMENT* df_element), int);
void df_retype(DATAFRAME *, DF_ELEMENT_TYPE, int);
void display_df(DATAFRAME *, int);
void show(DATAFRAME *);
#endif