Libraryless. Click here for Pure Java version (2566L/16K).
1 | static CharacterIterator characterIterator(S s, int from default 0) { |
2 | ret new CharacterIterator { |
3 | int n = l(s); |
4 | int i = from; |
5 | |
6 | public bool hasNext() { ret i < n; } |
7 | public char next() { ret s.charAt(i++); } |
8 | }; |
9 | } |
10 | |
11 | static CharacterIterator characterIterator(S s, int from, int _n) { |
12 | ret new CharacterIterator { |
13 | int n = min(l(s), from+_n); |
14 | int i = from; |
15 | |
16 | public bool hasNext() { ret i < n; } |
17 | public char next() { ret s.charAt(i++); } |
18 | }; |
19 | } |
20 | |
21 | static CharacterIterator characterIterator(char[] s, int from, int _n) { |
22 | ret new CharacterIterator { |
23 | int n = min(l(s), from+_n); |
24 | int i = from; |
25 | |
26 | public bool hasNext() { ret i < n; } |
27 | public char next() { ret s[i++]; } |
28 | }; |
29 | } |
Began life as a copy of #1029163
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: | #1029294 |
Snippet name: | characterIterator |
Eternal ID of this version: | #1029294/3 |
Text MD5: | 6ee69df9eafd6e23cf002fb1b71fe32a |
Transpilation MD5: | 020e9dfb37f54c28e1e972e2bba5ef7e |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-08-09 15:30:24 |
Source code size: | 756 bytes / 29 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 296 / 403 |
Version history: | 2 change(s) |
Referenced in: | [show references] |