This repository has been archived by the owner on Sep 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplanner.h
82 lines (67 loc) · 1.7 KB
/
planner.h
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
/*
*
* planner.h
*
* Baltasar Dinis 89416
* IAED project
*
* header file for planner.c
*
* defines the planner datatype
*
* the planner is the main data struct of the project planner
* internally, it has:
* a linked_list, which saves history
* a hashtable (with double hashing), saving ptrs to node on the linked_list
*
* with both of these structs, we can have:
* - lookup in ~ O(1)
* - insertion in ~ O(1)
* - deletion in ~ O(1)
* - transversing in O(n)
* - freeing in O(n)
*
* (~ O(1) because
*
*/
#ifndef PLANNER_H
#define PLANNER_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "list.h"
#include "hashtable.h"
#include "p_task.h"
typedef struct {
lnkd_list *l;
hashtable *htable;
unsigned long proj_duration;
bool path_freshness;
} planner;
/* selectors */
#define list(a) ((a).l)
#define htable(a) ((a).htable)
#define proj_duration(a) ((a).proj_duration)
#define path_freshness(a) ((a).path_freshness)
/* constructor */
planner *planner_();
/* destructor */
void free_planner(planner *p);
/* insert modifier */
void add_task(planner *p,
unsigned long id, char *descript, unsigned long dur,
unsigned long *ids, size_t n_ids);
/* remove modifier */
void remove_task_id(planner *p, unsigned long id);
/* print by duration */
void print_with_duration(planner *p, unsigned long dur);
/* print dependencies of a task */
void print_dependencies(planner *p, unsigned long id);
/* print critical path */
void print_critical_path(planner *p);
/* prints largest id */
void print_largest_id(planner *p);
/* prints id of the task with more dependencies */
void print_task_with_more_dependencies(planner *p);
#endif /* !PLANNER_H */