forked from bangoc/cgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd2wheap.h
55 lines (38 loc) · 1.34 KB
/
d2wheap.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
/*
(C) 2021 Nguyen Ba Ngoc (bangoc)
*/
#ifndef D2WHEAP_H_
#define D2WHEAP_H_
#include "gtp2wheap.h"
// ========== Khai báo hàm ===============
static int d2w_push_with_index(p2wheap_t h, long idx, double elem);
static double d2w_max(const p2wheap_t h);
static double d2w_get(const p2wheap_t h, long idx);
static double d2w_delete_max(p2wheap_t h);
static double d2w_deactivate_max(p2wheap_t h);
static double d2w_delete_max_index(p2wheap_t h, long *idx);
static int d2w_modify(p2wheap_t h, long idx, double elem);
// ========== Macro viết nhanh ===========
static int d2w_push_with_index(p2wheap_t h, long idx, double elem) {
return p2w_push_with_index(h, idx, gtype_value(d, elem), gtype_cmp_d);
}
static double d2w_max(const p2wheap_t h) {
return p2w_max(h).d;
}
static double d2w_get(const p2wheap_t h, long idx) {
return p2w_get(h, idx).d;
}
static double d2w_delete_max(p2wheap_t h) {
return p2w_delete_max(h, gtype_cmp_d).d;
}
static double d2w_deactivate_max(p2wheap_t h) {
return p2w_deactivate_max(h, gtype_cmp_d).d;
}
static double d2w_delete_max_index(p2wheap_t h, long *idx) {
return p2w_delete_max_index(h, idx, gtype_cmp_d).d;
}
static int d2w_modify(p2wheap_t h, long idx, double elem) {
return p2w_modify(h, idx, gtype_value(d, elem), gtype_cmp_d);
}
// ========== Định nghĩa hàm =============
#endif // D2WHEAP_H_