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

34
LINES

< > BotCompany Repo | #1029557 // stringToCharacterClassIterator

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

Libraryless. Click here for Pure Java version (2623L/17K).

static CharacterClassIterator stringToCharacterClassIterator(S s) {
  ret new stringToCharacterClassIterator_C(s);
}
  
sclass stringToCharacterClassIterator_C extends CharacterClassIterator {
  S s;
  int i, l;
  
  *() {}
  *(S *s) { l = l(s); }
  *(S *s, int *i, int *l) {}
  
  // no check because of method contract
  CharacterClassIterator acceptChar(char c) {
    ++i;
    this;
  }

  bool canEndHere() {
    ret i >= l;
  }
  
  bool canAcceptChar(char c) {
    ret i < l && s.charAt(i) == c;
  }

  CharRange acceptedCharRange() {
    ret i >= l ? null : singletonCharRange(s.charAt(i));
  }
  
  CharacterClassIterator cloneCCI() {
    ret new stringToCharacterClassIterator_C(s, i, l);
  }
}  

Author comment

Began life as a copy of #1029554

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: #1029557
Snippet name: stringToCharacterClassIterator
Eternal ID of this version: #1029557/8
Text MD5: acec490051793484b3f29d937a06a472
Transpilation MD5: 41fb162231cac70d453fc703843072a8
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-08-23 12:19:36
Source code size: 740 bytes / 34 lines
Pitched / IR pitched: No / No
Views / Downloads: 259 / 343
Version history: 7 change(s)
Referenced in: [show references]