Libraryless. Click here for Pure Java version (10058L/55K).
1 | static <A> L<A> moveItemsFirst(Cl<A> itemsToMove, Cl<A> l) { |
2 | if (empty(itemsToMove) || empty(l)) ret asList(l); |
3 | itemsToMove = asSet(itemsToMove); |
4 | var set = asSet(l); |
5 | L<A> out = emptyList(l(l)); |
6 | for (a : itemsToMove) |
7 | if (set.contains(a)) |
8 | out.add(a); |
9 | for (A a : l) |
10 | if (!itemsToMove.contains(a)) |
11 | out.add(a); |
12 | ret out; |
13 | } |
Began life as a copy of #1030795
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1036537 |
Snippet name: | moveItemsFirst - move elements to beginning of (cloned) list |
Eternal ID of this version: | #1036537/4 |
Text MD5: | 1704a467edf37fdfb2b6d3ec6cbd8df2 |
Transpilation MD5: | 441242b027197d0c93bc399d0fea34d2 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-01-30 20:01:35 |
Source code size: | 361 bytes / 13 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 167 / 224 |
Version history: | 3 change(s) |
Referenced in: | [show references] |