1 | static U nicestClosestKey(NavigableMap<U, ?> map, U key) { |
2 | U a = map.floorKey(key), b = map.ceilingKey(key); |
3 | if (b == null) ret a; |
4 | if (a == null) ret b; |
5 | int d1 = leven(str(key), str(a)); |
6 | int d2 = leven_limited(str(key), str(b), d1); |
7 | ret d1 <= d2 ? a : b; |
8 | } |
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: | 465 / 511 |
Version history: | 1 change(s) |
Referenced in: | [show references] |