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

18
LINES

< > BotCompany Repo | #1034294 // tempMapPutAll

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (5021L) is out of date.

1  
// assumes map never contains null values
2  
static <A, B> AutoCloseable tempMapPutAll(Map<A, B> map, Map<A, B> toAdd) {
3  
  if (map != null && nempty(toAdd)) {
4  
    new LPair<A, B> toRestore;
5  
    for (key, value : toAdd) {
6  
      if (key != null && value != null) {
7  
        B old = map.put(key, value);
8  
        if (!eq(old, value))
9  
          toRestore.add(pair(key, old));
10  
      }
11  
    }
12  
    ret -> {
13  
      for (p : toRestore)
14  
        mapPutOrRemove(map, p.a, p.b);
15  
    };
16  
  }
17  
  null;
18  
}

Author comment

Began life as a copy of #1034293

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034294
Snippet name: tempMapPutAll
Eternal ID of this version: #1034294/4
Text MD5: 3f7133dea613d18a7e7155dc0f320c55
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-05 23:12:50
Source code size: 498 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 139 / 220
Version history: 3 change(s)
Referenced in: [show references]