I have this program where it have some recursive function similar to this:
public static void lambda(HashSet<Integer> s){
if(end(s)){
return;
}
for(int i=0;i<w;i++){
HashSet<Integer> p = (HashSet) s.clone();
p.addAll(get_next_set());
do_stuff_to(p);
lambda(p);
}
}
What I'm doing is union every set with the set s. And run lambda on each one of the union. I run a profiler and found the c.clone() operation took 100% of the time of my code. Are there any way to speed this up considerably?