Libraryless. Click here for Pure Java version (3154L/18K).
srecord FixedMapClass(Class<? extends Map> clazz) implements IMapImplementationPolicy { bool sync = true, nullOnEmpty = false; public <A, B> Map<A, B> makeSingletonMap(A key, B value) { ret put(null, key, value); } public <A, B> Map<A, B> put(Map<A, B> map, A key, B value) { if (map == null) map = newInstance(clazz); if (sync) syncPut(map, key, value); else map.put(key, value); ret map; } public <A, B> Map<A, B> remove(Map<A, B> map, O key) { if (map == null) null; if (sync) syncRemove(map, (A) key); else map.remove(key); ret nullOnEmpty && empty(map) ? null : map; } }
Began life as a copy of #1031859
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1031860 |
Snippet name: | FixedMapClass - IMapImplementationPolicy using only one class (e.g. HashMap) |
Eternal ID of this version: | #1031860/11 |
Text MD5: | eccdb26db84f9690d30634757ec5d668 |
Transpilation MD5: | c60ddcfa5112575d7468bfbdaf6124a4 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-07-16 07:02:08 |
Source code size: | 682 bytes / 25 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 167 / 323 |
Version history: | 10 change(s) |
Referenced in: | #1031861 - BigLittleMapPolicy - uses two different map classes for small and big maps respectively #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |