Libraryless. Click here for Pure Java version (3839L/22K).
1 | static <A> A listGetOrCreate(L<A> l, int i, Class<? extends A> c) {
|
2 | ret listGetOrCreate(l, i, -> nuInstance(c)); |
3 | } |
4 | |
5 | static <A> A listGetOrCreate(L<A> l, int i, IF0<A> f) {
|
6 | if (l == null) null; |
7 | A a = get(l, i); |
8 | if (a == null) |
9 | listSet(l, i, a = f!); |
10 | ret a; |
11 | } |
12 | |
13 | static <A> A nuLike listGetOrCreate(Class<? extends A> c, L<A> l, int i) {
|
14 | ret listGetOrCreate(l, i, c); |
15 | } |
Began life as a copy of #1021808
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1022705 |
| Snippet name: | listGetOrCreate |
| Eternal ID of this version: | #1022705/5 |
| Text MD5: | f78abdbcae61ace9a416d2a92d717ac6 |
| Transpilation MD5: | c9003c886d121c1b5f06c6b5e1983577 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-10-15 20:54:46 |
| Source code size: | 394 bytes / 15 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 570 / 721 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |