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

24
LINES

< > BotCompany Repo | #1022360 // CombinedMap - only supports containsKey() and get()

JavaX fragment (include)

static class CombinedMap<A, B> extends AbstractMap<A, B> {
  new L<Map<A, B>> maps;

  *() {}
  *(Map<A, B>... maps) { addAllNonNulls(this.maps, maps); }
  <C extends Map<A, B>> *(Collection<C> maps) { addAllNonNulls(this.maps, maps); }

  public int size() { ret lengthLevel2_maps(maps); }
  public Set<Map.Entry<A, B>> entrySet() { fail(); }
  public bool containsKey(O o) {
    for (Map<A, B> map : maps)
      if (map.containsKey(o))
        true;
    false;
  }
  
  @Override
  public B get(O o) {
    for (Map<A, B> map : maps)
      if (map.containsKey(o))
        ret map.get(o);
    null;
  }
}

Author comment

Began life as a copy of #1021317

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1022360
Snippet name: CombinedMap - only supports containsKey() and get()
Eternal ID of this version: #1022360/5
Text MD5: 29640b5039bac0abe77b514567cda1f1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-24 19:24:21
Source code size: 629 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 198 / 638
Version history: 4 change(s)
Referenced in: [show references]