summaryrefslogtreecommitdiff
path: root/sort/parallelquick.go
diff options
context:
space:
mode:
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()
}