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

26
LINES

< > BotCompany Repo | #1029554 // CharacterClassIterator

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

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

1  
abstract sclass CharacterClassIterator {
2  
  // move method (go to next character)
3  
  // callee can assume that c is compatible with canAcceptChar
4  
  // return value can be this or follow-up iterator, but not null.
5  
  // Caller must, after this call, use the return value instead of the old iterator.
6  
7  
  abstract CharacterClassIterator acceptChar(char c);
8  
  
9  
  // query methods about next character
10  
  
11  
  abstract bool canEndHere();
12  
  bool canAcceptChar(char c) { ret contains(acceptedChars(), c); }
13  
  
14  
  // can be null
15  
  abstract Collection<Char> acceptedChars();
16  
  
17  
  // This character range must contain all the characters that
18  
  // are accepted by canAcceptChar at the current position.
19  
  // character range should be interpreted in a way compatible with an agreed-on char comparator.
20  
  // Method can return null if no chars are accepted at this position.
21  
  
22  
  abstract CharRange acceptedCharRange();
23  
  
24  
  // clone this iterator - may return same object if iterator is immutable
25  
  abstract CharacterClassIterator cloneCCI();
26  
}

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: #1029554
Snippet name: CharacterClassIterator
Eternal ID of this version: #1029554/15
Text MD5: 9f625633d2108af3397e0843ecb55856
Transpilation MD5: 33de7170b98c20e257f93ac75dbd9769
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:53:06
Source code size: 1049 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 270 / 572
Version history: 14 change(s)
Referenced in: [show references]