Java putting set into map
dictionary, java, set
Solution
One options would be this:
for (T value : set) {
map.put(value, 1);
}
Problem
Whats the quickest way to put a set into a map? ``` public class mySet<T> { private Map<T, Integer> map; public mySet(Set<T> set) { Object[] array = set.toArray(); for(int i =0; i< array.length; i++) { T v = (T)array[i]; map.put(v, 1); } } } ``` Right now, I just converted set into an array and loop through the array and putting them in one by one. Is there any better way to do this?