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

31
LINES

< > BotCompany Repo | #1029558 // CCI_Substring - CharacterClassIterator accepting a substring, then forwarding to a follow-up iterator

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

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

sclass CCI_Substring extends CharacterClassIterator {
  S s;
  int i, l;
  CharacterClassIterator next;

  *() {}
  *(S *s, int start, int end, CharacterClassIterator *next) { i = start; l = end; }
  
  // no check because of method contract
  CharacterClassIterator acceptChar(char c) {
    ret ++i >= l && next != null ? next : this;
  }

  bool canEndHere() {
    ret i >= l;
  }
  
  bool canAcceptChar(char c) {
    ret i < l && s.charAt(i) == c;
  }
  
  Cl<Char> acceptedChars() { ret i >= l ? null : ll(s.charAt(i)); }

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

Author comment

Began life as a copy of #1029557

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: #1029558
Snippet name: CCI_Substring - CharacterClassIterator accepting a substring, then forwarding to a follow-up iterator
Eternal ID of this version: #1029558/6
Text MD5: c9d0d6af98ff0f3f5fa1262fda186eec
Transpilation MD5: 196c40ab16ec24175756200219c10d7a
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:54:23
Source code size: 745 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 186 / 269
Version history: 5 change(s)
Referenced in: [show references]