-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.txt
70 lines (60 loc) · 1.59 KB
/
map.txt
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
#!/mnt/c/Users/Public/Documents/TKOM/interpreter
fun compare(first: Tuple<String, Map<String, int>>, second: Tuple<String, Map<String, int>>): int {
if (first.value["property_1"] > second.value["property_1"]) {
return 1;
} else if (first.value["property_1"] == second.value["property_1"]) {
return 0;
} else {
return -1;
}
}
fun reverse(first: Tuple<String, Map<String, int>>, second: Tuple<String, Map<String, int>>): int {
if (first.value["property_1"] > second.value["property_1"]) {
return -1;
} else if (first.value["property_1"] == second.value["property_1"]) {
return 0;
} else {
return 1;
}
}
fun main() {
Map<String, Map<String, int>> database = [
"id_1" : [
"property_1" : 1,
"property_2" : 2,
"property_3" : 3
],
"id_2" : [
"property_1" : 2,
"property_2" : 3,
"property_3" : 4
],
"id_3" : [
"property_1" : 3,
"property_2" : 4,
"property_3" : 5
]
];
Map<String, int> value = database.retrieveValue("id_1");
value.put("property_1", 4);
database.put("id_4", value);
print(@String value.contains("nothing"));
print(@String database.contains("id_1"));
for (Tuple<String, Map<String, int>> tuple : database.sortedIterable(compare)) {
print(tuple.key);
}
database.remove("id_1");
for (Tuple<String, Map<String, int>> tuple : database.sortedIterable(reverse)) {
print(tuple.key);
}
Comparator<Tuple<String, Map<String, int>>> comparator = compare;
["abc" : |
1 AS first,
2.0 AS second,
"3" AS third,
true AS fourth,
comparator AS fifth,
SELECT 1 AS a FROM database AS database AS sixth,
[] AS seventh
|].retrieveValue("abc");
}