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

10
LINES

< > BotCompany Repo | #1030224 // getAndRemove - get element from map and remove

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

Transpiled version (36L) is out of date.

static <A, B> B getAndRemove(Map<A, B> map, A a) {
  if (!containsKey(map, a)) null;
  B b = map.get(a);
  map.remove(a);
  ret b;
}

static <A, B> B getAndRemove(A a, Map<A, B> map) {
  ret getAndRemove(map, a);
}

Author comment

Began life as a copy of #1008055

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030224
Snippet name: getAndRemove - get element from map and remove
Eternal ID of this version: #1030224/2
Text MD5: ebc00806f9c9a30cc9aaf9a6ec53eef6
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-17 14:59:07
Source code size: 219 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 201 / 264
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)