Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

25
LINES

< > BotCompany Repo | #1007228 // findBackRefs (for concepts)

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (14780L/95K).

static <A extends Concept> L<A> findBackRefs(Collection<? extends Concept> concepts, Class<A> type) {
  new IdentityHashMap<A, Bool> l;
  for (Concept c : concepts)
    if (c.backRefs != null) for (Concept.Ref r : c.backRefs)
      if (instanceOf(r.concept(), type))
        l.put((A) r.concept(), true);
  ret asList(keys(l));
}

// TODO: sort by ID?
static <A extends Concept> L<A> findBackRefs(Concept c, Class<A> type) {
  new IdentityHashMap<A, Bool> l;
  if (c != null && c.backRefs != null) for (Concept.Ref r : c.backRefs)
    if (instanceOf(r.concept(), type))
      l.put((A) r.concept(), true);
  ret asList(keys(l));
}
  
static <A extends Concept> L<A> nuLike findBackRefs(Class<A> type, Concept c) {
  ret findBackRefs(c, type);
}

static Cl<Concept> findBackRefs(Concept c) {
  ret findBackRefs(c, Concept);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007228
Snippet name: findBackRefs (for concepts)
Eternal ID of this version: #1007228/7
Text MD5: 269b88cad69b592d6e1782ab9ae72b37
Transpilation MD5: c4efef0441a6e5e27a19043bd43524c1
Author: stefan
Category: javax / concepts
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-05 15:39:11
Source code size: 850 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 553 / 627
Version history: 6 change(s)
Referenced in: [show references]