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

1  
static int lCommonPrefixOfCharIterators(CharacterIterator it1, CharacterIterator it2) {
2  
  int n = 0;
3  
  while true {
4  
    if (!it1.hasNext() || !it2.hasNext()) ret n;
5  
    char a = it1.next(), b = it2.next();
6  
    if (a != b) ret n;
7  
    ++n;
8  
  }
9  
}
10  
11  
static int lCommonPrefixOfCharIterators(CharacterIterator it1, CharacterIterator it2, CharComparator comparator) {
12  
  if (comparator == null) ret lCommonPrefixOfCharIterators(it1, it2);
13  
  int n = 0;
14  
  while true {
15  
    if (!it1.hasNext() || !it2.hasNext()) ret n;
16  
    char a = it1.next(), b = it2.next();
17  
    if (comparator.compare(a, b) != 0) ret n;
18  
    ++n;
19  
  }
20  
}

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