From dda16974366e91036b32d0eeea33b766c2439feb Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 8 Aug 2020 17:32:23 +0100 Subject: fortune not found Quick commit --- sort/parallelquick.go | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'sort/parallelquick.go') diff --git a/sort/parallelquick.go b/sort/parallelquick.go index cde4b5e..7533d35 100644 --- a/sort/parallelquick.go +++ b/sort/parallelquick.go @@ -6,36 +6,31 @@ import ( ) func ParallelQuick(a ds.ArrayList) ds.ArrayList { - Shuffle(a) + //Shuffle(a) parallelQuick(a) return a } func parallelQuick(a ds.ArrayList) { l := len(a) - if l <= 10 { - Insertion(a) + + if l < 1000 { + quick(a) return } j := quickPartition(a) + var wg sync.WaitGroup + wg.Add(2) - if l >= 1000 { - var wg sync.WaitGroup - wg.Add(2) - defer wg.Wait() - - go func() { - parallelQuick(a[0:j]) - wg.Done() - }() - go func() { - parallelQuick(a[j+1:]) - wg.Done() - }() - return - } + go func() { + parallelQuick(a[0:j]) + wg.Done() + }() + go func() { + parallelQuick(a[j+1:]) + wg.Done() + }() - parallelQuick(a[0:j]) - parallelQuick(a[j+1:]) + wg.Wait() } -- cgit v1.2.3