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).

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

Author comment

Began life as a copy of #1030164

download  show line numbers  debug dex   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

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: 22 / 36
Version history: 2 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1030171 & http://1030171.tinybrain.de