header of vote.c
More...
#include "lib/sign.h"
#include "lib/dataio.h"
#include "lib/types.h"
#include <stddef.h>
Go to the source code of this file.
◆ HashCell
Structure for storing a single Key.
◆ HashTable
Structure to store Key objects as an array.
◆ compute_winner()
Simulates an election process and returns the winner. Checks if declarations are valid and update vote numbers for each candidate.
- Parameters
-
decl | list of declaration |
cadidates | list of candidates |
voters | list of voters |
sizeC | size of candidates hashtable |
sizeV | size of voters hashtable |
- Returns
- Key* copy of the key of the winning candidate
◆ create_hashcell()
Create a hashcell object. Copies key.
- Parameters
-
- Returns
- HashCell*
◆ create_hashcell_raw()
Create a hashcell raw object. Takes ownership of key.
- Parameters
-
- Returns
- HashCell*
◆ create_hashtable()
Create a HashTable object containing keys elements. Keys position are found with find_position()..
- Parameters
-
keys | keys to store |
size | size of the table |
- Returns
- HashTable*
◆ find_position()
Find the position to place k at in the HasTable t. If the position in the array is taken, find a new one using linear probing. If no position was found, returns the originally found position of hash_function().
- Parameters
-
t | Table to store in |
k | Key to store |
- Returns
- uint32 : found position.
◆ free_hashcell()
Free a HasCell object.
- Parameters
-
◆ free_hashtable()
Free a HashTable object and all the elements of the table. (Correspond to delete_hashtable in the project subject).
- Parameters
-
◆ hash_function()
uint32 hash_function |
( |
const Key * |
key, |
|
|
int |
size |
|
) |
| |
Hash function for Key arrays (HashTable).
- Parameters
-
key | |
size | length of the array |
- Returns
- uint32 : position in the array