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

30
LINES

< > BotCompany Repo | #1004686 // addAll - generalizes Collection.addAll + synonym of addComponents

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

Libraryless. Click here for Pure Java version (5207L/29K).

1  
static <A, B extends A> void addAll(Collection<A> c, Iterable<B> b) {
2  
  if (c != null && b != null) for (A a : b) c.add(a);
3  
}
4  
5  
static <A, B extends A> bool addAll(Collection<A> c, Collection<B> b) {
6  
  ret c != null && b != null && c.addAll(b);
7  
}
8  
9  
static <A, B extends A> bool addAll(Collection<A> c, B... b) {
10  
  ret c != null && b != null && c.addAll(Arrays.asList(b));
11  
}
12  
13  
ifclass Collector
14  
static <A, B extends A> void addAll(Collector<A> c, Iterable<B> b) {
15  
  if (c != null && b != null) for (A a : b) c.add(a);
16  
}
17  
endif
18  
19  
static <A, B> Map<A, B> addAll(Map<A, B> a, Map<? extends A,? extends B> b) {
20  
  if (a != null && b != null) a.putAll(b);
21  
  ret a;
22  
}
23  
24  
static <A extends Container> A addAll(A c, Cl<? extends Component> components) {
25  
  ret addComponents(c, components);
26  
}
27  
28  
static <A extends Container> A addAll(A c, Component... components) {
29  
  ret addComponents(c, components);
30  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004686
Snippet name: addAll - generalizes Collection.addAll + synonym of addComponents
Eternal ID of this version: #1004686/17
Text MD5: 2439c692b51c981cec8448307653d58c
Transpilation MD5: 9e13ae9a25a64ff57ac506c2f3549513
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-08 01:30:20
Source code size: 912 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 883 / 1377
Version history: 16 change(s)
Referenced in: [show references]