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

22
LINES

< > BotCompany Repo | #1024837 // Lowest_withRunnerUp

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

Libraryless. Click here for Pure Java version (2013L/13K).

sclass Lowest_withRunnerUp<A> extends Lowest<A> {
  A runnerUp;
  double runnerUpScore;

  bool put(A a, double score) {
    bool change = false;
    synchronized(this) {
      if (a != null && isNewBest(score)) {
        runnerUp = best;
        runnerUpScore = this.score;
        best = a;
        this.score = score;
        set change;
      }
    }
    if (change)
      pcallF(onChange);
    ret change;
  }
  
  synchronized Pair<A, Double> runnerUpPair() { ret runnerUp == null ? null : main.pair(runnerUp, runnerUpScore); }
}

Author comment

Began life as a copy of #1006448

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024837
Snippet name: Lowest_withRunnerUp
Eternal ID of this version: #1024837/4
Text MD5: cdcee0a3e882cd33ab55f8f0d561694b
Transpilation MD5: 9c1f65f1169736f1a9636c024cb47999
Author: stefan
Category: javax / genetic optimization
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-26 19:37:31
Source code size: 556 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 165 / 538
Version history: 3 change(s)
Referenced in: [show references]