static U nicestClosestKey(NavigableMap<U, ?> map, U key) { U a = map.floorKey(key), b = map.ceilingKey(key); if (b == null) ret a; if (a == null) ret b; int d1 = leven(str(key), str(a)); int d2 = leven_limited(str(key), str(b), d1); ret d1 <= d2 ? a : b; }
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: | #1008021 |
Snippet name: | nicestClosestKey - floorKey or ceilingKey depending on Levenshtein distance |
Eternal ID of this version: | #1008021/2 |
Text MD5: | 6f50dca871da08b77864ac0cd730405c |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-04-20 19:14:24 |
Source code size: | 275 bytes / 8 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 464 / 510 |
Version history: | 1 change(s) |
Referenced in: | [show references] |