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

10
LINES

< > BotCompany Repo | #1034026 // IntMinMax - collect minimum and maximum value

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

Libraryless. Click here for Pure Java version (37L/1K).

sclass IntMinMax {
  int min = Int.MAX_VALUE, max = Int.MIN_VALUE;
  
  void add(int i) {
    if (i < min) min = i;
    if (i > max) max = i;
  }
  
  int rangeLength() { ret max-min; }
}

Author comment

Began life as a copy of #1034025

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034026
Snippet name: IntMinMax - collect minimum and maximum value
Eternal ID of this version: #1034026/2
Text MD5: 4c48839d114992f78b6c577fe73a4ef6
Transpilation MD5: 0a74df4295f807b13212b1658cb6c9ed
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-17 17:59:18
Source code size: 196 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 145 / 234
Version history: 1 change(s)
Referenced in: [show references]