summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2020-10-16 09:23:27 +0100
committerPaul Buetow <paul@buetow.org>2020-10-16 09:23:27 +0100
commit2f700943480cf9767bf5090feeac626af742c1c8 (patch)
tree313b7b795b3a84aaef92c4b39c174167b9aa95ea
parentda8837c515cbefadce9bdbb5e035398f89b283ec (diff)
migrate to gomodules
-rw-r--r--queue/elementarypriority.go2
-rw-r--r--queue/heappriority.go18
-rw-r--r--queue/queue_test.go3
-rw-r--r--sort/bottomupmerge.go2
-rw-r--r--sort/insertion.go2
-rw-r--r--sort/merge.go2
-rw-r--r--sort/parallelmerge.go3
-rw-r--r--sort/parallelquick.go3
-rw-r--r--sort/quick.go3
-rw-r--r--sort/quick3way.go2
-rw-r--r--sort/selection.go2
-rw-r--r--sort/shell.go2
-rw-r--r--sort/shuffle.go3
-rw-r--r--sort/sort_test.go3
14 files changed, 28 insertions, 22 deletions
diff --git a/queue/elementarypriority.go b/queue/elementarypriority.go
index d5b3f4a..5212afa 100644
--- a/queue/elementarypriority.go
+++ b/queue/elementarypriority.go
@@ -1,7 +1,7 @@
package queue
import (
- "algorithms/ds"
+ "github.com/snonux/algorithms/ds"
)
type ElementaryPriority struct {
diff --git a/queue/heappriority.go b/queue/heappriority.go
index d96975c..f88b9b3 100644
--- a/queue/heappriority.go
+++ b/queue/heappriority.go
@@ -1,7 +1,7 @@
package queue
import (
- "algorithms/ds"
+ "github.com/snonux/algorithms/ds"
)
type HeapPriority struct {
@@ -9,11 +9,11 @@ type HeapPriority struct {
}
func NewHeapPriority(capacity int) *HeapPriority {
- q := HeapPriority{
+ q := HeapPriority{
ElementaryPriority: ElementaryPriority{make(ds.ArrayList, 0, capacity), capacity},
}
- // Index 0 unused
+ // Index 0 unused
q.a = append(q.a, 0)
return &q
}
@@ -23,12 +23,12 @@ func (q *HeapPriority) Empty() bool {
}
func (q *HeapPriority) Size() int {
- return len(q.a)-1
+ return len(q.a) - 1
}
func (q *HeapPriority) Insert(a int) {
q.a = append(q.a, a)
- q.swim(len(q.a)-1)
+ q.swim(len(q.a) - 1)
}
func (q *HeapPriority) Max() (max int) {
@@ -50,7 +50,7 @@ func (q *HeapPriority) DeleteMax() int {
default:
a := q.a[1]
// Last index
- max := len(q.a)-1
+ max := len(q.a) - 1
q.a.Swap(1, max)
q.a = q.a[0:max]
@@ -63,13 +63,13 @@ func (q *HeapPriority) DeleteMax() int {
func (q *HeapPriority) swim(k int) {
for k > 1 && q.a[k/2] < q.a[k] {
q.a.Swap(k/2, k)
- k = k/2
+ k = k / 2
}
}
func (q *HeapPriority) sink(k int) {
// Last index
- max := len(q.a)-1
+ max := len(q.a) - 1
for 2*k <= max {
// Left child
@@ -77,7 +77,7 @@ func (q *HeapPriority) sink(k int) {
// Go to right child?
if j < max && q.a[j] < q.a[j+1] {
- j++
+ j++
}
// Found my spot in the heap
diff --git a/queue/queue_test.go b/queue/queue_test.go
index 2b32210..31ad020 100644
--- a/queue/queue_test.go
+++ b/queue/queue_test.go
@@ -1,9 +1,10 @@
package queue
import (
- "algorithms/ds"
"fmt"
"testing"
+
+ "github.com/snonux/algorithms/ds"
)
const minLength int = 1
diff --git a/sort/bottomupmerge.go b/sort/bottomupmerge.go
index c0ae4fd..467c4e0 100644
--- a/sort/bottomupmerge.go
+++ b/sort/bottomupmerge.go
@@ -1,7 +1,7 @@
package sort
import (
- "algorithms/ds"
+ "github.com/snonux/algorithms/ds"
)
func BottomUpMerge(a ds.ArrayList) ds.ArrayList {
diff --git a/sort/insertion.go b/sort/insertion.go
index 203d4f2..bba3698 100644
--- a/sort/insertion.go
+++ b/sort/insertion.go
@@ -1,7 +1,7 @@
package sort
import (
- "algorithms/ds"
+ "github.com/snonux/algorithms/ds"
)
func Insertion(a ds.ArrayList) ds.ArrayList {
diff --git a/sort/merge.go b/sort/merge.go
index 4d5a862..e2cfe01 100644
--- a/sort/merge.go
+++ b/sort/merge.go
@@ -1,7 +1,7 @@
package sort
import (
- "algorithms/ds"
+ "github.com/snonux/algorithms/ds"
)
func Merge(a ds.ArrayList) ds.ArrayList {
diff --git a/sort/parallelmerge.go b/sort/parallelmerge.go
index c379883..5186632 100644
--- a/sort/parallelmerge.go
+++ b/sort/parallelmerge.go
@@ -1,8 +1,9 @@
package sort
import (
- "algorithms/ds"
"sync"
+
+ "github.com/snonux/algorithms/ds"
)
func ParallelMerge(a ds.ArrayList) ds.ArrayList {
diff --git a/sort/parallelquick.go b/sort/parallelquick.go
index 7533d35..195a2c8 100644
--- a/sort/parallelquick.go
+++ b/sort/parallelquick.go
@@ -1,8 +1,9 @@
package sort
import (
- "algorithms/ds"
"sync"
+
+ "github.com/snonux/algorithms/ds"
)
func ParallelQuick(a ds.ArrayList) ds.ArrayList {
diff --git a/sort/quick.go b/sort/quick.go
index f3502e5..3502cf0 100644
--- a/sort/quick.go
+++ b/sort/quick.go
@@ -1,8 +1,9 @@
package sort
import (
- "algorithms/ds"
"math/rand"
+
+ "github.com/snonux/algorithms/ds"
)
func Quick(a ds.ArrayList) ds.ArrayList {
diff --git a/sort/quick3way.go b/sort/quick3way.go
index 8434111..76e15c8 100644
--- a/sort/quick3way.go
+++ b/sort/quick3way.go
@@ -1,7 +1,7 @@
package sort
import (
- "algorithms/ds"
+ "github.com/snonux/algorithms/ds"
)
// Quick3Way uses a 3-way partitioning so it is more efficient dealing with duplicates
diff --git a/sort/selection.go b/sort/selection.go
index a28437c..9b42b55 100644
--- a/sort/selection.go
+++ b/sort/selection.go
@@ -1,7 +1,7 @@
package sort
import (
- "algorithms/ds"
+ "github.com/snonux/algorithms/ds"
)
func Selection(a ds.ArrayList) ds.ArrayList {
diff --git a/sort/shell.go b/sort/shell.go
index 5fab584..821dfc8 100644
--- a/sort/shell.go
+++ b/sort/shell.go
@@ -1,7 +1,7 @@
package sort
import (
- "algorithms/ds"
+ "github.com/snonux/algorithms/ds"
)
func Shell(a ds.ArrayList) ds.ArrayList {
diff --git a/sort/shuffle.go b/sort/shuffle.go
index 3611f7b..cf42a85 100644
--- a/sort/shuffle.go
+++ b/sort/shuffle.go
@@ -1,8 +1,9 @@
package sort
import (
- "algorithms/ds"
"math/rand"
+
+ "github.com/snonux/algorithms/ds"
)
func Shuffle(a ds.ArrayList) ds.ArrayList {
diff --git a/sort/sort_test.go b/sort/sort_test.go
index 2ca6f91..d785d55 100644
--- a/sort/sort_test.go
+++ b/sort/sort_test.go
@@ -1,9 +1,10 @@
package sort
import (
- "algorithms/ds"
"fmt"
"testing"
+
+ "github.com/snonux/algorithms/ds"
)
// Store results here to avoid compiler optimizations