Libraryless. Click here for Pure Java version (10166L/56K).
1 | final sclass DoubleRange implements Comparable<DoubleRange> { |
2 | gettable double start; |
3 | gettable double end; |
4 | |
5 | *() {} |
6 | *(double *start, double *end) {} |
7 | |
8 | [stdEq] |
9 | |
10 | double length() { ret end-start; } |
11 | bool isEmpty() { ret start >= end; } |
12 | double center() { ret (start+end)/2; } |
13 | |
14 | sS _fieldOrder = "start end"; |
15 | |
16 | toString { ret "[" + start + ";" + end + "]"; } |
17 | |
18 | @Override public int compareTo(DoubleRange r) { |
19 | int c = cmp(start, r.start); |
20 | if (c != 0) ret c; |
21 | ret cmp(end, r.end); |
22 | } |
23 | |
24 | bool contains(double d) { |
25 | ret d >= start && d <= end; |
26 | } |
27 | |
28 | DoubleRange sort() { |
29 | ret start > end ? doubleRange(end, start) : this; |
30 | } |
31 | } |
Began life as a copy of #1008631
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019120 |
Snippet name: | class DoubleRange - range of doubles (start/end) |
Eternal ID of this version: | #1019120/9 |
Text MD5: | a009e097cd785914ac0d4314b5e1cd87 |
Transpilation MD5: | cf631cb8b6baa373462eaa7d93188be6 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-03-14 13:26:23 |
Source code size: | 698 bytes / 31 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 510 / 1291 |
Version history: | 8 change(s) |
Referenced in: | [show references] |