summaryrefslogtreecommitdiff
path: root/sort/parallelquick.go
diff options
context:
space:
mode:
authorPaul Buetow <pbuetow@mimecast.com>2020-08-08 17:32:23 +0100
committerPaul Buetow <pbuetow@mimecast.com>2020-08-08 17:32:23 +0100
commitdda16974366e91036b32d0eeea33b766c2439feb (patch)
treef76a3fd0a08e5daa18c65271db55a3f290882a59 /sort/parallelquick.go
parent36573e16d9e8b511aec24a82797a5d13ceef6aa4 (diff)
fortune not found
Quick commit
Diffstat (limited to 'sort/parallelquick.go')
-rw-r--r--sort/parallelquick.go35
1 files changed, 15 insertions, 20 deletions
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()
}