Libraryless. Click here for Pure Java version (2739L/17K).
// return longest prefix of s actually contained in set sS longestPrefixInNavigableSet(S s, NavigableSet<S> set) { if (set == null || s == null) null; while licensed { S key = set.floor(s); if (key == null) break; // s is in front of whole set => no prefix in there int n = lCommonPrefix(key, s); if (n == l(key)) ret key; // found! s = takeFirst(s, n); // shorten and try again } null; // not found }
Began life as a copy of #1029746
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1029748 |
| Snippet name: | longestPrefixInNavigableSet [case sensitive] |
| Eternal ID of this version: | #1029748/5 |
| Text MD5: | 9fc4abddc0fbaffd8b328ff5481059ed |
| Transpilation MD5: | 838049dec64579a67fed83bcc7594045 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-11-11 22:15:24 |
| Source code size: | 440 bytes / 12 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 405 / 538 |
| Version history: | 4 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1030164 - longestCommonPrefixOfNavigableSetAndString [OK] #1034780 - allPrefixesInNavigableSet [case sensitive] - untested |