Skip to content
Snippets Groups Projects
Verified Commit a475111d authored by orestis.malaspin's avatar orestis.malaspin
Browse files

updated the slides

parent 329d6f52
No related branches found
No related tags found
No related merge requests found
Pipeline #15190 passed
......@@ -107,3 +107,67 @@ bool search(table, key, value) {
}
```
# Écrivons le code!
* Mais avant:
* Quelles sont les structures de données dont nous avons besoin?
* Y a-t-il des fonctions auxiliaires à écrire?
* Écrire les signatures des fonctions.
. . .
## Structures de données
. . .
```C
typedef enum {empty, deleted, occupied};
typedef ... key_t;
typedef ... value_t;
typedef struct _cell_t {
key_t key;
value_t value;
state_t state;
} cell_t;
typedef struct _hm {
cell_t *table;
int capacity;
int size;
} hm;
```
# Écrivons le code!
## Fonctions auxiliaires
. . .
```C
static int hash(key_t key);
static int rehash(int index, key_t key);
static int find_index(hm h, key_t key);
```
## Signature de l'API
```C
void hm_init(hm *h, int capacity);
void hm_destroy(hm *h);
bool hm_set(hm *h, key_t key, value_t *value);
bool hm_get(hm h, key_t key, value_t *value);
bool hm_remove(hm *h, key_t key, value_t *value);
bool hm_search(hm h, key_t key);
void hm_print(hm h);
```
# Live code session!
0. Offered to you by ProtonVPN!
. . .
1. Like the video.
2. Subscribe to the channel.
3. Use our one time voucher for ProtonVPN: `PAULISAWESOME`.
4. Consider donating on our patreon.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment