|
@@ -354,3 +354,41 @@ Boolean function set_in(a: Element, b: Element):
|
|
|
|
|
|
Element function set_in_node(a: Element, b: Element):
|
|
|
return dict_in_node(a, b)!
|
|
|
+
|
|
|
+String function reverseKeyLookup(dict : Element, element : Element):
|
|
|
+ // TODO don't know if this AL will actually work...
|
|
|
+ Integer nr_in
|
|
|
+ Integer nr_out
|
|
|
+ Integer counter
|
|
|
+ Element link
|
|
|
+
|
|
|
+ nr_in = read_nr_in(element)
|
|
|
+ counter = 0
|
|
|
+ while (counter < nr_in):
|
|
|
+ if (element_eq(read_edge_src(read_in(element, counter)), dict)):
|
|
|
+ // Got a match
|
|
|
+ return (read_edge_dst(read_out(read_in(element, counter), 0)))!
|
|
|
+
|
|
|
+ counter = counter + 1
|
|
|
+
|
|
|
+ return string_join(string_join("(unknown: ", cast_e2s(element)), " )")!
|
|
|
+
|
|
|
+Element function reverseKeyLookupMulti(dict : Element, element : Element):
|
|
|
+ // TODO don't know if this AL will actually work...
|
|
|
+ Integer nr_in
|
|
|
+ Integer nr_out
|
|
|
+ Integer counter
|
|
|
+ Element link
|
|
|
+ Element result
|
|
|
+
|
|
|
+ result = set_create()
|
|
|
+ nr_in = read_nr_in(element)
|
|
|
+ counter = 0
|
|
|
+ while (counter < nr_in):
|
|
|
+ if (element_eq(read_edge_src(read_in(element, counter)), dict)):
|
|
|
+ // Got a match
|
|
|
+ set_add(result, read_edge_dst(read_out(read_in(element, counter), 0)))
|
|
|
+
|
|
|
+ counter = counter + 1
|
|
|
+
|
|
|
+ return result!
|