wielowatkowy quicksort

0

witam, dostalem za zadanie uwielowatkowic quicksorta, wiec w tym celu zainstalowalem biblioteke boost. po wielu probach udalo mi sie doprowadzic kod do wysypu bledow, ktora nie przekracza 100 :P

oto kod:

int KruskalList::quicksort(int p,int r)
{
    int q;
    if(p < r)
    {
           q = partition(p,r);
           
		   boost::thread* pThreads[2] = { NULL, NULL };
		   pThreads[0] = new boost::thread(boost::bind(&KruskalList::quicksort, p, q-1, 0));
		   pThreads[1] = new boost::thread(boost::bind(&KruskalList::quicksort, q+1, r, 0));

		   pThreads[0]->join();
		   pThreads[1]->join();
    }   
    return 0;
}

bledy:

 1>C:\Program Files\boost\boost_1_46_1\boost/bind/mem_fn_template.hpp(271): error C2784: 'T *boost::get_pointer(const boost::scoped_ptr<T> &)' : could not deduce template argument for 'const boost::scoped_ptr<T> &' from 'int'
1>          C:\Program Files\boost\boost_1_46_1\boost/smart_ptr/scoped_ptr.hpp(124) : see declaration of 'boost::get_pointer'
1>          C:\Program Files\boost\boost_1_46_1\boost/bind/mem_fn_template.hpp(286) : see reference to function template instantiation 'R boost::_mfi::mf2<R,T,A1,A2>::call<U,A1,A2>(U &,const void *,B1 &,B2 &) const' being compiled
1>          with
1>          [
1>              R=int,
1>              T=KruskalList,
1>              A1=int,
1>              A2=int,
1>              U=int,
1>              B1=int,
1>              B2=int
1>          ]
1>          C:\Program Files\boost\boost_1_46_1\boost/bind/bind.hpp(382) : see reference to function template instantiation 'R boost::_mfi::mf2<R,T,A1,A2>::operator ()<int>(U &,A1,A2) const' being compiled
1>          with
1>          [
1>              R=int,
1>              T=KruskalList,
1>              A1=int,
1>              A2=int,
1>              U=int
1>          ]
1>          C:\Program Files\boost\boost_1_46_1\boost/bind/bind_template.hpp(20) : see reference to function template instantiation 'R boost::_bi::list3<A1,A2,A3>::operator ()<int,F,boost::_bi::list0>(boost::_bi::type<T>,F &,A &,long)' being compiled
1>          with
1>          [
1>              R=int,
1>              A1=boost::_bi::value<int>,
1>              A2=boost::_bi::value<int>,
1>              A3=boost::_bi::value<int>,
1>              F=boost::_mfi::mf2<int,KruskalList,int,int>,
1>              T=int,
1>              A=boost::_bi::list0
1>          ]
1>          C:\Program Files\boost\boost_1_46_1\boost/bind/bind_template.hpp(18) : while compiling class template member function 'int boost::_bi::bind_t<R,F,L>::operator ()(void)'
1>          with
1>          [
1>              R=int,
1>              F=boost::_mfi::mf2<int,KruskalList,int,int>,
1>              L=boost::_bi::list3<boost::_bi::value<int>,boost::_bi::value<int>,boost::_bi::value<int>>
1>          ]
1>          testThread.cpp(131) : see reference to class template instantiation 'boost::_bi::bind_t<R,F,L>' being compiled
1>          with
1>          [
1>              R=int,
1>              F=boost::_mfi::mf2<int,KruskalList,int,int>,
1>              L=boost::_bi::list3<boost::_bi::value<int>,boost::_bi::value<int>,boost::_bi::value<int>>
1>          ]
1>C:\Program Files\boost\boost_1_46_1\boost/bind/mem_fn_template.hpp(271): error C2784: 'T *boost::get_pointer(const std::auto_ptr<_Ty> &)' : could not deduce template argument for 'const std::auto_ptr<_Ty> &' from 'int'
1>          C:\Program Files\boost\boost_1_46_1\boost/get_pointer.hpp(25) : see declaration of 'boost::get_pointer'
1>C:\Program Files\boost\boost_1_46_1\boost/bind/mem_fn_template.hpp(271): error C2784: 'T *boost::get_pointer(T *)' : could not deduce template argument for 'T *' from 'int'
1>          C:\Program Files\boost\boost_1_46_1\boost/get_pointer.hpp(18) : see declaration of 'boost::get_pointer'
1>C:\Program Files\boost\boost_1_46_1\boost/bind/mem_fn_template.hpp(271): error C2784: 'T *boost::get_pointer(const boost::reference_wrapper<T> &)' : could not deduce template argument for 'const boost::reference_wrapper<T> &' from 'int'
1>          C:\Program Files\boost\boost_1_46_1\boost/ref.hpp(182) : see declaration of 'boost::get_pointer'
1>C:\Program Files\boost\boost_1_46_1\boost/bind/mem_fn_template.hpp(271): error C2784: 'T *boost::get_pointer(const boost::shared_ptr<X> &)' : could not deduce template argument for 'const boost::shared_ptr<X> &' from 'int'
1>          C:\Program Files\boost\boost_1_46_1\boost/smart_ptr/shared_ptr.hpp(550) : see declaration of 'boost::get_pointer'
1>C:\Program Files\boost\boost_1_46_1\boost/bind/mem_fn_template.hpp(271): error C2784: 'T *boost::get_pointer(const boost::intrusive_ptr<T> &)' : could not deduce template argument for 'const boost::intrusive_ptr<T> &' from 'int'
1>          C:\Program Files\boost\boost_1_46_1\boost/smart_ptr/intrusive_ptr.hpp(238) : see declaration of 'boost::get_pointer'
1>

z gory dzieki za pomoc

0

Jeśli pierwszym argumentem boost::bind jest wskaźnik na metodę, to drugim musi być obiekt klasy, na rzecz którego metoda ta zostanie wywołana. Więc coś w ten deseń:

 

boost::thread t1(boost::bind(&KruskalList::quicksort, boost::ref(*this), p, q-1));
boost::thread t2(boost::bind(&KruskalList::quicksort, boost::ref(*this), q+1, r));
t1.join();
t2.join();

0

dziala, wielkie dzieki :)

1 użytkowników online, w tym zalogowanych: 0, gości: 1