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

17
LINES

< > BotCompany Repo | #1010798 // expiringHelperMap

JavaX fragment (include)

// remove : voidfunc(K)
static <K> LinkedHashMap<K, Long> expiringHelperMap(final int timeOut, fO remove) {
  ret new LinkedHashMap<K, Long>() {
    protected bool removeEldestEntry(Map.Entry<K, Long> eldest) {
      long time = now();
      if (time - eldest.getValue() > timeOut) {
        Iterator<Map.Entry<K, Long>> i = entrySet().iterator();
        Map.Entry<K, Long> e = i.next();
        do {
            i.remove();
            pcallF(remove, e.getKey());
        } while (i.hasNext() && time - (e = i.next()).getValue() > timeOut);
      }
      false;
    }
  };
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1010798
Snippet name: expiringHelperMap
Eternal ID of this version: #1010798/5
Text MD5: 770b44ddedeadd500ef659546d213e2d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-03 18:52:50
Source code size: 592 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 356 / 380
Version history: 4 change(s)
Referenced in: [show references]