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

23
LINES

< > BotCompany Repo | #1019120 - class DoubleRange - range of doubles (start/end)

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

Libraryless. Click here for Pure Java version (4008L/23K).

final sclass DoubleRange implements Comparable<DoubleRange> {
  gettable double start;
  gettable double end;
  
  *() {}
  *(double *start, double *end) {}
  
  [stdEq]
  
  double length() { ret end-start; }
  bool isEmpty() { ret start >= end; }
  double center() { ret (start+end)/2; }
  
  sS _fieldOrder = "start end";
  
  toString { ret "[" + start + ";" + end + "]"; }
  
  @Override public int compareTo(DoubleRange r) {
    int c = cmp(start, r.start);
    if (c != 0) ret c;
    ret cmp(end, r.end);
  }
}

Author comment

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/7
Text MD5: c3537365e59b97b2334c50630af17ac5
Transpilation MD5: 587c809acb5901204ec8f934cce93d2d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-11 17:03:08
Source code size: 539 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 230 / 877
Version history: 6 change(s)
Referenced in: [show references]