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

14
LINES

< > BotCompany Repo | #1030551 // indexOfMaxEntryInDoubleArray

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

Libraryless. Click here for Pure Java version (2709L/16K).

static int indexOfMaxEntryInDoubleArray(double[] a) {
  if (empty(a)) ret -1;
  int bestIndex = 0;
  double bestValue = a[0];
  int n = l(a);
  for (int i = 1; i < n; i++) {
    double x = a[i];
    if (x > bestValue) {
      bestIndex = i;
      bestValue = x;
    }
  }
  ret bestIndex;
}

Author comment

Began life as a copy of #1024770

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030551
Snippet name: indexOfMaxEntryInDoubleArray
Eternal ID of this version: #1030551/2
Text MD5: f7e1914237df692dd198a3d7b9b9b962
Transpilation MD5: 76f731283062ad27a4905153dc9c6c7d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-01-07 17:46:01
Source code size: 303 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 166 / 243
Version history: 1 change(s)
Referenced in: [show references]