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

17
LINES

< > BotCompany Repo | #1007503 // WeakAssoc

JavaX fragment (include)

// uses identity to compare a and new value
static class WeakAssoc<A, B> {
  O f; // func(A) -> B
  WeakReference<A> a;
  B b;
  
  *() {}
  *(O *f) {}

  synchronized B get(A a) {
    if (a != (this.a != null ? this.a.get() : null)) {
      b = (B) callF(f, a);
      this.a = new WeakReference(a);
    }
    ret b;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wtqryiryparv

No comments. add comment

Snippet ID: #1007503
Snippet name: WeakAssoc
Eternal ID of this version: #1007503/3
Text MD5: 9cc877571b659caa2e3bdc91e1023637
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-25 17:28:57
Source code size: 338 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 556 / 1771
Version history: 2 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)