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

23
LINES

< > BotCompany Repo | #1018479 // lines_iterator

JavaX fragment (include)

1  
static IterableIterator<S> lines_iterator(fS s) {
2  
  if (s == null) ret emptyIterableIterator();
3  
  ret iteratorFromFunction(new F0<S> {
4  
    int start = 0;
5  
    
6  
    S get() {
7  
      int i = toLines_nextLineBreak(s, start);
8  
      if (i < 0) {
9  
        S toReturn = s.length() > start ? s.substring(start) : null;
10  
        start = s.length();
11  
        ret toReturn;
12  
      }
13  
14  
      S toReturn = s.substring(start, i);
15  
      if (s.charAt(i) == '\r' && i+1 < s.length() && s.charAt(i+1) == '\n')
16  
        i += 2;
17  
      else
18  
        ++i;
19  
      start = i;
20  
      ret toReturn;
21  
    }
22  
  });
23  
}

Author comment

Began life as a copy of #1001950

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1018479
Snippet name: lines_iterator
Eternal ID of this version: #1018479/6
Text MD5: e06d09cecad0c28157281c7e27303f19
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-01 18:12:19
Source code size: 597 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 406 / 445
Version history: 5 change(s)
Referenced in: [show references]