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

22
LINES

< > BotCompany Repo | #1017455 // class DerivedMap - base map + additions

JavaX fragment (include)

static class DerivedMap<A, B> extends AbstractMap<A, B> {
  Map<A, B> base;
  Map<A, B> additions = new HashMap;
  
  *() {}
  *(Map<A, B> *base) {}
  *(Map<A, B> *base, Map<A, B> *additions) {}
  
  public B get(Object key) {
    B b = additions.get(key);
    if (b != null) return b;
    return base.get(key);
  }
  
  public B put(A key, B value) {
    return additions.put(key, value);
  }
  
  public Set<Map.Entry<A,B>> entrySet() {
    throw fail();
  }
}

Author comment

Began life as a copy of #1001027

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017455
Snippet name: class DerivedMap - base map + additions
Eternal ID of this version: #1017455/3
Text MD5: ce3a0bfc02a4e07881e809726c307818
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-22 13:41:28
Source code size: 485 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 367 / 939
Version history: 2 change(s)
Referenced in: [show references]