List of utility methods to do List to Set
Set | listToSet(final BsonArray array) list To Set if (array == null || array.isEmpty()) { return Collections.emptySet(); } else { Set<String> set = new HashSet<String>(); for (BsonValue value : array) { set.add(value.asString().getValue()); return set; ... |
Set | listToSet(List list) list To Set Set set = new HashSet(); if (list != null) { for (Iterator iter = list.iterator(); iter.hasNext();) { Object object = (Object) iter.next(); if (object != null) { set.add(object); return set; |
Set | toSet(List to Set Set<Object> targets = Collections.emptySet();
targets.addAll(sources);
return targets;
|
Set | toSet(List Returns the List as an Set either ordered or as-is, if the comparator is null. Set<String> set; if (comparator == null) set = new LinkedHashSet<>(); else set = new TreeSet<>(comparator); set.addAll(list); return set; |
Set | toSet(List to Set return Collections.unmodifiableSet(new HashSet<>(list)); |
Set | toSet(List to Set Set<T> set = new HashSet<T>(); for (T t : list) { if (!set.contains(t)) { set.add(t); return set; |
Set | toSet(Optional
Returns a new Set populated by all elements in the given list of strings Returns an empty set if the given Optional is empty, or if the list contained in the Optional is empty List<String> elements = list.orElse(Collections.emptyList()); return new HashSet<>(elements); |