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.

static LS splitAtSpaceTokenizer(S s) {
  new ArrayList<S> tok;
  int l = l(s);
  
  int i = 0, n = 0;
  while (i < l) {
    int j = i;
    char c;
    
    // scan for whitespace
    while (j < l) {
      c = s.charAt(j);
      if (isSpace(c))
        ++j;
      else
        break;
    }
    
    tok.add(javaTok_substringN(s, i, j));
    ++n;
    i = j;
    if (i >= l) break;

    // scan for non-whitespace
    
    while (j < l && !isSpace(s.charAt(j)))
      ++j;
      
    tok.add(javaTok_substringC(s, i, j));
    ++n;
    i = j;
  }
  
  if ((tok.size() % 2) == 0) tok.add("");
  return tok;  
}

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: 229 / 319
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1035764 - splitAtSpaceIterator