-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtreemap.c
87 lines (59 loc) · 1.56 KB
/
treemap.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "treemap.h"
typedef struct TreeNode TreeNode;
struct TreeNode {
Pair* pair;
TreeNode * left;
TreeNode * right;
TreeNode * parent;
};
struct TreeMap {
TreeNode * root;
TreeNode * current;
int (*lower_than) (void* key1, void* key2);
};
int is_equal(TreeMap* tree, void* key1, void* key2){
if(tree->lower_than(key1,key2)==0 &&
tree->lower_than(key2,key1)==0) return 1;
else return 0;
}
TreeNode * createTreeNode(void* key, void * value) {
TreeNode * new = (TreeNode *)malloc(sizeof(TreeNode));
if (new == NULL) return NULL;
new->pair = (Pair *)malloc(sizeof(Pair));
new->pair->key = key;
new->pair->value = value;
new->parent = new->left = new->right = NULL;
return new;
}
TreeMap * createTreeMap(int (*lower_than) (void* key1, void* key2)) {
//new->lower_than = lower_than;
return NULL;
}
void insertTreeMap(TreeMap * tree, void* key, void * value) {
}
TreeNode * minimum(TreeNode * x){
return NULL;
}
void removeNode(TreeMap * tree, TreeNode* node) {
}
void eraseTreeMap(TreeMap * tree, void* key){
if (tree == NULL || tree->root == NULL) return;
if (searchTreeMap(tree, key) == NULL) return;
TreeNode* node = tree->current;
removeNode(tree, node);
}
Pair * searchTreeMap(TreeMap * tree, void* key) {
return NULL;
}
Pair * upperBound(TreeMap * tree, void* key) {
return NULL;
}
Pair * firstTreeMap(TreeMap * tree) {
return NULL;
}
Pair * nextTreeMap(TreeMap * tree) {
return NULL;
}