Libraryless. Click here for Pure Java version (137L/1K).
1 | static <A> L<A> withoutNulls(Iterable<A> l) { |
2 | if (l cast L) |
3 | if (!containsNulls(l)) ret l; |
4 | new L<A> l2; |
5 | for (A a : l) |
6 | if (a != null) |
7 | l2.add(a); |
8 | ret l2; |
9 | } |
10 | |
11 | static <A, B> Map<A, B> withoutNulls(Map<A, B> map) { |
12 | Map<A, B> map2 = similarEmptyMap(map); |
13 | for (A a : keys(map)) |
14 | if (a != null) { |
15 | B b = map.get(a); |
16 | if (b != null) |
17 | map2.put(a, b); |
18 | } |
19 | ret map2; |
20 | } |
21 | |
22 | static <A> L<A> withoutNulls(A[] l) { |
23 | new L<A> l2; |
24 | if (l != null) for (A a : l) |
25 | if (a != null) |
26 | l2.add(a); |
27 | ret l2; |
28 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004239 |
Snippet name: | withoutNulls - drop null values from list, or null keys and null values from map |
Eternal ID of this version: | #1004239/10 |
Text MD5: | 2a828f945b9a9113af504f45c77f41bb |
Transpilation MD5: | c6aacef92838a8f4dcb907035a2029d6 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-05-28 15:21:59 |
Source code size: | 564 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 616 / 713 |
Version history: | 9 change(s) |
Referenced in: | [show references] |