1 | // f : Concept -> bool |
2 | static Concept conceptGraphSearch(Concept c, O f) { |
3 | ret conceptGraphSearch_impl(c, f, new IdentityHashMap); |
4 | } |
5 | |
6 | static Concept conceptGraphSearch_impl(Concept c, O f, IdentityHashMap<Concept, Concept> seen) { |
7 | if (seen.containsKey(c)) null; |
8 | if (callPred(f, c)) ret c; |
9 | seen.put(c, c); |
10 | |
11 | for (S field : conceptFields(c)) { |
12 | O val = cget(c, field); |
13 | if (val instanceof Concept) { |
14 | Concept d = conceptGraphSearch_impl(val/Concept, f, seen); |
15 | if (d != null) ret d; |
16 | } |
17 | } |
18 | null; |
19 | } |
Began life as a copy of #1005477
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005490 |
Snippet name: | conceptGraphSearch - find a concept in graph that matches predicate |
Eternal ID of this version: | #1005490/1 |
Text MD5: | 3114b988017904405f02c3603d3fc1bf |
Author: | stefan |
Category: | javax / concepts |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-11-23 14:05:05 |
Source code size: | 547 bytes / 19 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 670 / 659 |
Referenced in: | [show references] |