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

9
LINES

< > BotCompany Repo | #1030171 // longestCommonPrefixOfNavigableSetAndList

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2743L/17K).

1  
// return longest common prefix of s an an entry of set
2  
static <A> L<A> longestCommonPrefixOfNavigableSetAndList(L<A> s, NavigableSet<L<A>> set, Comparator<A> comparator) {
3  
  if (set == null || s == null) null;
4  
  L<A> a = set.floor(s), b = set.higher(s);
5  
  int n1 = lCommonPrefix_lists_comparator(a, s, comparator);
6  
  int n2 = lCommonPrefix_lists_comparator(b, s, comparator);
7  
  int n = max(n1, n2);
8  
  ret takeFirst(s, n);
9  
}

Author comment

Began life as a copy of #1030164

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030171
Snippet name: longestCommonPrefixOfNavigableSetAndList
Eternal ID of this version: #1030171/3
Text MD5: 390f17bb11d505d925016e5cd75a80fe
Transpilation MD5: 561cffa69cc40ed75005a7190f4024a5
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-11 23:44:02
Source code size: 432 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 103 / 150
Version history: 2 change(s)
Referenced in: [show references]