1 | // it's unclear whether the end is inclusive or exclusive |
2 | // (usually exclusive I guess) |
3 | sclass IntRange { |
4 | int start, end; |
5 | |
6 | *() {} |
7 | *(int *start, int *end) {} |
8 | *(IntRange r) { start = r.start; end = r.end; } |
9 | |
10 | [stdEq] |
11 | |
12 | final int length() { ret end-start; } |
13 | final bool empty() { ret start >= end; } |
14 | final bool isEmpty() { ret start >= end; } |
15 | |
16 | sS _fieldOrder = "start end"; |
17 | |
18 | toString { ret "[" + start + ";" + end + "]"; } |
19 | |
20 | bool contains(int i) { ret i >= start && i <= end; } |
21 | } |
Began life as a copy of #1005873
download show line numbers debug dex old transpilations
Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1008631 |
Snippet name: | class IntRange - range of ints (start/end) |
Eternal ID of this version: | #1008631/17 |
Text MD5: | 7a96be33c5f41deea4ee53c63217489b |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-03-14 21:33:18 |
Source code size: | 527 bytes / 21 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 746 / 2302 |
Version history: | 16 change(s) |
Referenced in: | [show references] |