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

15
LINES

< > BotCompany Repo | #1011181 // mapToHashSet - map function, return as hash set

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

Libraryless. Click here for Pure Java version (5067L/28K).

1  
ifndef EnforceFunctionTypes
2  
static HashSet mapToHashSet(O f, Iterable l) {
3  
  HashSet x = l cast Cl ? new HashSet(l.size()) : new HashSet;
4  
  if (l != null) for (O o : l)
5  
    x.add(callF(f, o));
6  
  ret x;
7  
}
8  
endifndef
9  
10  
static <A, B> HashSet<B> lambdaMapLike mapToHashSet(IF1<A, B> f, Iterable<A> l) {
11  
  HashSet<B> x = l cast Cl ? new HashSet(l.size()) : new HashSet;
12  
  if (l != null) for (A o : l)
13  
    x.add(f.get(o));
14  
  ret x;
15  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1011181
Snippet name: mapToHashSet - map function, return as hash set
Eternal ID of this version: #1011181/16
Text MD5: 4178a119c7d0666f4b36eb5efe691031
Transpilation MD5: feada48935ffc3e67627db9cfdaf3797
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-12 22:58:27
Source code size: 439 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 518 / 663
Version history: 15 change(s)
Referenced in: [show references]