-
Notifications
You must be signed in to change notification settings - Fork 0
/
matches_dict_entry.c
52 lines (44 loc) · 1.24 KB
/
matches_dict_entry.c
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
#include <malloc.h>
typedef struct matches_dict_entry{
int* reads;
int* value;
int count; //numero di volte in cui appaiono le read, va a sostituire il dizionareo min_shared_dict
}matches_dict_entry;
matches_dict_entry* createMDictEntry(int *r);
int update_matches_dict_entry(matches_dict_entry* entry,int first,int second);
/*
in: r
out: matches_dict_entry
viene creato un puntatore a una entry che ha come chiave r (sarebbe reads)
*/
matches_dict_entry* createMDictEntry(int *r){
matches_dict_entry* p = (matches_dict_entry*)malloc(sizeof(matches_dict_entry));
p->reads=r;
p->value=NULL;
p->count=0;
return p;
}
/*
in: entry,first,second
out: 1 se è stato possibile aggiornare i valori in entry con first e second
*/
int update_matches_dict_entry(matches_dict_entry* entry,int first,int second){
entry->count++;
if(!entry->value){
entry->value=(int*)malloc(4*sizeof(int));
entry->value[0]=first;
entry->value[1]=second;
entry->value[2]=first;
entry->value[3]=second;
return 1;
}
if(entry->value[0]>first){
entry->value[0]=first;
entry->value[1]=second;
}
if(entry->value[2]<first){
entry->value[2]=first;
entry->value[3]=second;
}
return 1;
}