-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolumn.h
More file actions
150 lines (126 loc) · 3.6 KB
/
column.h
File metadata and controls
150 lines (126 loc) · 3.6 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#ifndef CDATAFRAME_PEREZ_LENAIN_BENSIFI_COLUMN_H
#define CDATAFRAME_PEREZ_LENAIN_BENSIFI_COLUMN_H
enum enum_type
{
NULLVAL = 1 , UINT, INT, CHAR, FLOAT, DOUBLE, STRING, STRUCTURE
};
typedef enum enum_type ENUM_TYPE;
typedef union column_type{
unsigned int uint_value;
signed int int_value;
char char_value;
float float_value;
double double_value;
char* string_value;
void* struct_value;
}COL_TYPE;
typedef struct COLUMN{
char* title;
unsigned int size;
unsigned int max_size;
ENUM_TYPE column_type;
COL_TYPE **data;
unsigned long long int *index;
// index valid
// 0 : no index
//-1 : invalid index
// 1 : valid index
int valid_index;
// direction de tri : Ascendant ou Descendant
// 0 : ASC
// 1 : DESC
int sort_dir;
}COLUMN;
/**
* @brief: Initialize the column
* @param1: Type of the column
* @param2: Title of the column as a string
* @return: Pointer to the column
*/
COLUMN *create_column(ENUM_TYPE type, char *title);
/**
* @brief: Insert a new value into a column
* @param1: Pointer to the column
* @param2: Pointer to the value to insert
* @return: 1 if the value is correctly inserted 0 otherwise
*/
int insert_value(COLUMN *col, void *value);
/**
* @brief: Delete a value in the column
* @param1: Column
* @param2: Position of the value the user wants to get rid of within the data column
*/
void delete_value_column(COLUMN *col, int location);
/**
* @brief: Free the space allocated by a column
* @param: Pointer to the column
*/
void delete_column(COLUMN **col);
/**
* @brief: Convert a value into a string
* @param1: Pointer to the column
* @param2: Position of the value in the data array
* @param3: The string in which the value will be written
* @param4: Maximum size of the string
*/
void convert_value(COLUMN *col, unsigned long long int i, char *str, int size);
/**
* @brief: Display the content of a column
* @param: Pointer to the column to display
*/
void print_col(COLUMN* col);
/**
* @brief: Looks for a value in the CDataFrame
* @param1: Pointer to the CDataFrame
* @param2: value wanted
* @param3: value type
* @return: 1 if the value exists, 0 otherwise
*/
int exist_col(COLUMN* col, char *value);
/**
* @brief: Shows the numbers of cells match with the value in the CDataFrame
* @param1: Pointer to the CDataFrame
* @param2: value wanted
* @param3: value type
* @return: number of cells equals to the value
*/
int cellsequal_col(COLUMN* col, char *value);
/**
* @brief: Shows the numbers of cells superior than the value in the CDataFrame
* @param1: Pointer to the CDataFrame
* @param2: value wanted
* @param3: value type
* @return: number of cells superior to the value
*/
int cellssup_col(COLUMN* col, char *value);
/**
* @brief: Shows the numbers of cells inferior than the value in the CDataFrame
* @param1: Pointer to the CDataFrame
* @param2: value wanted
* @param3: value type
* @return: number of cells inferior to the value
*/
int cellsinf_col(COLUMN* col, char *value);
/**
* @brief: Display the content of a sorted column
* @param: Pointer to a column
*/
void print_col_by_index(COLUMN *col);
/**
* @brief: Create a column by inputs from the user
* @return: Pointer to the said column
*/
COLUMN *create_col_user();
/**
* @brief: Print values in a column
* @param1: Column
* @param2: Index
*/
void print_val_in_col(COLUMN* col , unsigned long long int index);
/**
* @brief: Insert a new value into a column
* @param: Column
* @return: 1 if the value was insert inside the column, 0 otherwise
*/
int insert_user_val(COLUMN *col);
#endif //CDATAFRAME_PEREZ_LENAIN_BENSIFI_COLUMN_H