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

8
LINES

< > BotCompany Repo | #1027844 // nestedMapRemove - remove entry from map in map; remove inner map if empty

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

Libraryless. Click here for Pure Java version (2477L/16K).

static <A, B, C> C nestedMapRemove(Map<A, Map<B, C>> map, A a, B b) {
  if (map == null) null;
  Map<B, C> map2 = map.get(a);
  if (map2 == null) null;
  C oldValue = map2.remove(b);
  if (empty(map2)) map.remove(a);
  ret oldValue;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1027844
Snippet name: nestedMapRemove - remove entry from map in map; remove inner map if empty
Eternal ID of this version: #1027844/1
Text MD5: f3b7ae624ea83bd6921f2a81bd2ffbdd
Transpilation MD5: 2e0163fe5c85eadfc6535c6fa39f2618
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-15 02:14:11
Source code size: 241 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 209 / 314
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)