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

17
LINES

< > BotCompany Repo | #1020431 // aggressivelyCollectLatinCharacterSequencesOfMaxLength_intersperseNulls - return some nulls when scanning for too long

JavaX fragment (include)

1  
static ItIt<S> aggressivelyCollectLatinCharacterSequencesOfMaxLength_intersperseNulls(final int maxLength, final InputStream in) {
2  
  if (in == null) ret emptyItIt();
3  
  ret iteratorFromFunction_withEndMarker(func -> S {
4  
    int c, countdown = 65536;
5  
    while (licensed() && (c = in.read()) >= 0)
6  
      if (isLatinChar((char) c)) {
7  
        new StringBuilder buf;
8  
        buf.append((char) c);
9  
        while (licensed() && l(buf) < maxLength && (c = in.read()) >= 0
10  
          && isLatinChar((char) c))
11  
          buf.append((char) c);
12  
        ret str(buf);
13  
      } else
14  
        if (--countdown < 0) null;
15  
    ret endMarker();
16  
  });
17  
}

Author comment

Began life as a copy of #1020426

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020431
Snippet name: aggressivelyCollectLatinCharacterSequencesOfMaxLength_intersperseNulls - return some nulls when scanning for too long
Eternal ID of this version: #1020431/4
Text MD5: deaecbbf8f511a079b2d53879ecc9779
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-21 16:54:40
Source code size: 646 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 320 / 348
Version history: 3 change(s)
Referenced in: [show references]