September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,10 +1,10 @@
|
|||
quick_sort(L) -> qs(L, erlang:system_info(schedulers)).
|
||||
quick_sort(L) -> qs(L, trunc(math:log2(erlang:system_info(schedulers)))).
|
||||
|
||||
qs([],_) -> [];
|
||||
qs([H|T], N) when N > 1 ->
|
||||
qs([H|T], N) when N > 0 ->
|
||||
{Parent, Ref} = {self(), make_ref()},
|
||||
spawn(fun()-> Parent ! {l1, Ref, qs([E||E<-T, E<H], N-2)} end),
|
||||
spawn(fun()-> Parent ! {l2, Ref, qs([E||E<-T, H =< E], N-2)} end),
|
||||
spawn(fun()-> Parent ! {l1, Ref, qs([E||E<-T, E<H], N-1)} end),
|
||||
spawn(fun()-> Parent ! {l2, Ref, qs([E||E<-T, H =< E], N-1)} end),
|
||||
{L1, L2} = receive_results(Ref, undefined, undefined),
|
||||
L1 ++ [H] ++ L2;
|
||||
qs([H|T],_) ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue