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

18
LINES

< > BotCompany Repo | #1034025 // DoubleMinMax - collect minimum and maximum value

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

Transpiled version (9982L) is out of date.

sclass DoubleMinMax {
  double min = Double.NaN, max = Double.NaN;
  
  bool isEmpty() { ret isNaN(min); }
  
  void add(double d) {
    if (isNaN(min) || d < min) min = d;
    if (isNaN(max) || d > max) max = d;
  }
  
  double rangeLength() { ret max-min; }
  
  toString { ret renderVars(+min, +max); }
  
  DoubleRange range() {
    ret isEmpty() ? null : doubleRange(min, max);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034025
Snippet name: DoubleMinMax - collect minimum and maximum value
Eternal ID of this version: #1034025/4
Text MD5: 5e3ece1ad8fad6bf6ca81c17ffc65443
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-01-16 14:51:46
Source code size: 405 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 159 / 274
Version history: 3 change(s)
Referenced in: [show references]