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

19
LINES

< > BotCompany Repo | #1035012 // concatMapToSet - map, then join sets. uses HashSet

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

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

static <A, B, C extends Iterable<B>> Set<B> concatMapToSet(Iterable<A> l, IF1<A, C> f) {
  new Set<B> set;
  if (l != null)
    for (a : l)
      addAll(set, f.get(a));
  ret set;
}

static <A, B, C extends Iterable<B>> Set<B> lambdaMapLike concatMapToSet(IF1<A, C> f, Iterable<A> l) {
  ret concatMapToSet(l, f);
}

static <A, B, C extends Iterable<B>> Set<B> lambdaMapLike concatMapToSet(IF1<A, C> f, A[] l) {
  new Set<B> set;
  if (l != null)
    for (a : l)
      addAll(set, f.get(a));
  ret set;
}

Author comment

Began life as a copy of #1005492

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035012
Snippet name: concatMapToSet - map, then join sets. uses HashSet
Eternal ID of this version: #1035012/4
Text MD5: 1cda596bdd1712257459e13221502d7d
Transpilation MD5: f8ba8d72a7a6448f3b36c4fc7c7951bd
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-22 23:08:42
Source code size: 522 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 117 / 177
Version history: 3 change(s)
Referenced in: [show references]