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)

1  
static class CombinedMap<A, B> extends AbstractMap<A, B> {
2  
  new L<Map<A, B>> maps;
3  
4  
  *() {}
5  
  *(Map<A, B>... maps) { addAllNonNulls(this.maps, maps); }
6  
  <C extends Map<A, B>> *(Collection<C> maps) { addAllNonNulls(this.maps, maps); }
7  
8  
  public int size() { ret lengthLevel2_maps(maps); }
9  
  public Set<Map.Entry<A, B>> entrySet() { fail(); }
10  
  public bool containsKey(O o) {
11  
    for (Map<A, B> map : maps)
12  
      if (map.containsKey(o))
13  
        true;
14  
    false;
15  
  }
16  
  
17  
  @Override
18  
  public B get(O o) {
19  
    for (Map<A, B> map : maps)
20  
      if (map.containsKey(o))
21  
        ret map.get(o);
22  
    null;
23  
  }
24  
}

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: 202 / 644
Version history: 4 change(s)
Referenced in: [show references]