Java creation of new set too slow

Posted by Mgccl on Stack Overflow See other posts from Stack Overflow or by Mgccl
Published on 2010-03-29T01:08:52Z Indexed on 2010/03/29 1:13 UTC
Read the original article Hit count: 275

Filed under:
|

I have this program where it have some recursive function similar to this:

lambda(HashSet<Integer> s){
    for(int i=0;i<w;i++){
        HashSet<Integer> p = (HashSet) s.clone();
        p.addAll(get_next_set());
        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?

© Stack Overflow or respective owner

Related posts about java

Related posts about set