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.

// assumes map never contains null values
static <A, B> AutoCloseable tempMapPutAll(Map<A, B> map, Map<A, B> toAdd) {
  if (map != null && nempty(toAdd)) {
    new LPair<A, B> toRestore;
    for (key, value : toAdd) {
      if (key != null && value != null) {
        B old = map.put(key, value);
        if (!eq(old, value))
          toRestore.add(pair(key, old));
      }
    }
    ret -> {
      for (p : toRestore)
        mapPutOrRemove(map, p.a, p.b);
    };
  }
  null;
}

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: 72 / 128
Version history: 3 change(s)
Referenced in: [show references]