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

36
LINES

< > BotCompany Repo | #1028697 // splitAtSpaceTokenizer

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

Transpiled version (2494L) is out of date.

1  
static LS splitAtSpaceTokenizer(S s) {
2  
  new ArrayList<S> tok;
3  
  int l = l(s);
4  
  
5  
  int i = 0, n = 0;
6  
  while (i < l) {
7  
    int j = i;
8  
    char c;
9  
    
10  
    // scan for whitespace
11  
    while (j < l) {
12  
      c = s.charAt(j);
13  
      if (isSpace(c))
14  
        ++j;
15  
      else
16  
        break;
17  
    }
18  
    
19  
    tok.add(javaTok_substringN(s, i, j));
20  
    ++n;
21  
    i = j;
22  
    if (i >= l) break;
23  
24  
    // scan for non-whitespace
25  
    
26  
    while (j < l && !isSpace(s.charAt(j)))
27  
      ++j;
28  
      
29  
    tok.add(javaTok_substringC(s, i, j));
30  
    ++n;
31  
    i = j;
32  
  }
33  
  
34  
  if ((tok.size() % 2) == 0) tok.add("");
35  
  return tok;  
36  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1028697
Snippet name: splitAtSpaceTokenizer
Eternal ID of this version: #1028697/3
Text MD5: f0abab394e9659cc52c1aea48e4ffd4b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-05 21:32:26
Source code size: 640 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 228 / 319
Version history: 2 change(s)
Referenced in: [show references]