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.

1  
sclass DoubleMinMax {
2  
  double min = Double.NaN, max = Double.NaN;
3  
  
4  
  bool isEmpty() { ret isNaN(min); }
5  
  
6  
  void add(double d) {
7  
    if (isNaN(min) || d < min) min = d;
8  
    if (isNaN(max) || d > max) max = d;
9  
  }
10  
  
11  
  double rangeLength() { ret max-min; }
12  
  
13  
  toString { ret renderVars(+min, +max); }
14  
  
15  
  DoubleRange range() {
16  
    ret isEmpty() ? null : doubleRange(min, max);
17  
  }
18  
}

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: 160 / 277
Version history: 3 change(s)
Referenced in: [show references]