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

16
LINES

< > BotCompany Repo | #1013292 // scoredSearch2 - with maxResults, faster?

JavaX fragment (include)

1  
static L<S> scoredSearch2(int maxResults, S query, Iterable<S> data) {
2  
  new MultiMap<Int, String> map;
3  
  L<S> prepared = scoredSearch_prepare(query);
4  
  for (S s : data) {
5  
    int score = scoredSearch_score(s, prepared);
6  
    if (score == 0) continue;
7  
    map.put(score, s);
8  
  }
9  
  new L<S> out;
10  
  for (int score : keysDesc(map)) {
11  
    if (l(out) >= maxResults) break;
12  
    int need = maxResults-l(out);
13  
    out.addAll(takeFirst(need, map.get(score)));
14  
  }
15  
  ret out;
16  
}

Author comment

Began life as a copy of #1007531

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: #1013292
Snippet name: scoredSearch2 - with maxResults, faster?
Eternal ID of this version: #1013292/1
Text MD5: 84e4d2e481cd722fd1daffce84a222f9
Author: stefan
Category: javax / text
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-31 08:00:40
Source code size: 481 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 476 / 505
Referenced in: [show references]