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).

1  
static CharacterClassIterator stringToCharacterClassIterator(S s) {
2  
  ret new stringToCharacterClassIterator_C(s);
3  
}
4  
  
5  
sclass stringToCharacterClassIterator_C extends CharacterClassIterator {
6  
  S s;
7  
  int i, l;
8  
  
9  
  *() {}
10  
  *(S *s) { l = l(s); }
11  
  *(S *s, int *i, int *l) {}
12  
  
13  
  // no check because of method contract
14  
  CharacterClassIterator acceptChar(char c) {
15  
    ++i;
16  
    this;
17  
  }
18  
19  
  bool canEndHere() {
20  
    ret i >= l;
21  
  }
22  
  
23  
  bool canAcceptChar(char c) {
24  
    ret i < l && s.charAt(i) == c;
25  
  }
26  
27  
  CharRange acceptedCharRange() {
28  
    ret i >= l ? null : singletonCharRange(s.charAt(i));
29  
  }
30  
  
31  
  CharacterClassIterator cloneCCI() {
32  
    ret new stringToCharacterClassIterator_C(s, i, l);
33  
  }
34  
}  

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: 260 / 344
Version history: 7 change(s)
Referenced in: [show references]