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

24
LINES

< > BotCompany Repo | #1005339 // xsearch - flexible concept searcher [dev.]

JavaX fragment (include)

1  
// returns a list of var mappings
2  
static L<Map<ISearchVar, O>> xsearch(L<ISearchVar> vars, Class c, O... params) {
3  
  for (ISearchVar v : vars) v.set(null); // reset vars
4  
  params = expandParams(c, params);
5  
  new L<Map<ISearchVar, O>> l;
6  
  for (A concept : list(c))
7  
    if (searchConcept_checkParams(concept, params)) {
8  
      // Success. Record var mapping
9  
      l.add(xsearch_makeVarMapping(vars));
10  
      // Reset vars
11  
      for (ISearchVar v : vars) v.set(null); // reset vars
12  
    }
13  
  ret l;
14  
}
15  
16  
static Map<ISearchVar, O> xsearch_makeVarMapping(L<ISearchVar> vars) {
17  
  new HashMap<ISearchVar, O> map;
18  
  for (ISearchVar v : vars) {
19  
    O o = v.get();
20  
    if (o != null)
21  
      map.put(v, o);
22  
  }
23  
  ret map;
24  
}

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: #1005339
Snippet name: xsearch - flexible concept searcher [dev.]
Eternal ID of this version: #1005339/1
Text MD5: 1f93ae3fe794d1305a5e937391d0d527
Author: stefan
Category: javax / concepts
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-11-07 13:52:51
Source code size: 729 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 415 / 415
Referenced in: [show references]