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

11
LINES

< > BotCompany Repo | #1030164 // longestCommonPrefixOfNavigableSetAndString [OK]

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

Transpiled version (2740L) is out of date.

// return longest common prefix of s an an entry of set
sS longestCommonPrefixOfNavigableSetAndString(S s, NavigableSet<S> set) {
  if (set == null || s == null) null;
  S a = set.floor(s), b = set.higher(s);
  int n1 = lCommonPrefix(a, s), n2 = lCommonPrefix(b, s);
  ifdef longestCommonPrefixOfNavigableSetAndString_debug
    printVars_str("longestCommonPrefixOfNavigableSetAndString", +s, +set, +n1, +n2);
  endifdef
  int n = Math.max(n1, n2);
  ret takeFirst_string(s, n);
}

Author comment

Began life as a copy of #1029748

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1030164
Snippet name: longestCommonPrefixOfNavigableSetAndString [OK]
Eternal ID of this version: #1030164/8
Text MD5: d591ee2215834ceee19b62d3d350b09a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-12 10:50:13
Source code size: 489 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 211 / 306
Version history: 7 change(s)
Referenced in: [show references]