-
Notifications
You must be signed in to change notification settings - Fork 0
/
hash_min_sharing_dict.c
59 lines (47 loc) · 1.61 KB
/
hash_min_sharing_dict.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
53
54
55
56
57
58
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <limits.h>
#include "min_sharing_dict.h"
typedef struct hash_msdict{
min_sharing_dict** dicts_list;//lista di puntatori a dizionari min_sharing_dict
int size; //numero di entry della lista
} hash_msdict;
void initHashMSDict(hash_msdict* msdict,int size);
int add_in_hash_msdict(min_sharing_dict** dict,int* reads);
void viewHashMSDict(hash_msdict* msdict);
/*
in: msdict,size
out: void
il dizionario msdict viene inizializzato con un numero di entry pari al paramentro size passato dall'utente
*/
void initHashMSDict(hash_msdict* msdict,int size){
msdict->size=size;
msdict->dicts_list=(min_sharing_dict**)malloc(msdict->size * sizeof(min_sharing_dict*));
for(int i=0;i<msdict->size;i++) msdict->dicts_list[i]=NULL;
}
/*
in: dict,reads
out: 1 se l'inserimento della read che ha per chiave reads all'interno del dizionario dict va a buon fine
*/
int add_in_hash_msdict(min_sharing_dict** dict,int* reads){
if(!*dict){
*dict = (min_sharing_dict*)malloc(sizeof(min_sharing_dict));
initMSDict(*dict);
}
return add_in_msdict(*dict,reads);
}
/*
in: msdict
vengono visualizzate tutte le entry presenti nella lista di dizionari
*/
void viewHashMSDict(hash_msdict* msdict){
for(int i=0;i<msdict->size;i++){
if(msdict->dicts_list[i]){
//printf("ciao\n");
//printf("%d\n",hdict->dicts_list[i]->size);
viewMSDict(msdict->dicts_list[i]);
}
}
}