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

20
LINES

< > BotCompany Repo | #1029460 // lCommonPrefixOfCharIterators

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

Libraryless. Click here for Pure Java version (52L/1K).

static int lCommonPrefixOfCharIterators(CharacterIterator it1, CharacterIterator it2) {
  int n = 0;
  while true {
    if (!it1.hasNext() || !it2.hasNext()) ret n;
    char a = it1.next(), b = it2.next();
    if (a != b) ret n;
    ++n;
  }
}

static int lCommonPrefixOfCharIterators(CharacterIterator it1, CharacterIterator it2, CharComparator comparator) {
  if (comparator == null) ret lCommonPrefixOfCharIterators(it1, it2);
  int n = 0;
  while true {
    if (!it1.hasNext() || !it2.hasNext()) ret n;
    char a = it1.next(), b = it2.next();
    if (comparator.compare(a, b) != 0) ret n;
    ++n;
  }
}

Author comment

Began life as a copy of #1029161

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1029460
Snippet name: lCommonPrefixOfCharIterators
Eternal ID of this version: #1029460/3
Text MD5: cd69c065151e216b10eb78a9fabb487c
Transpilation MD5: 4812041dcce52e23c126b62a1dba9249
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-08-23 09:52:16
Source code size: 627 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 137 / 207
Version history: 2 change(s)
Referenced in: [show references]