Skip to content

Commit 219a5a4

Browse files
author
hypntc
committed
fix comment style and function naming
1 parent 85fcd67 commit 219a5a4

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

sort/bucketsort.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "github.com/TheAlgorithms/Go/constraints"
44

55
// Bucket sorts a slice. It is mainly useful
66
// when input is uniformly distributed over a range.
7-
func BucketSort[T constraints.Number](arr []T) []T {
7+
func Bucket[T constraints.Number](arr []T) []T {
88
// early return if the array too small
99
if len(arr) <= 1 {
1010
return arr

sort/pancakesort.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ package sort
22

33
import "github.com/TheAlgorithms/Go/constraints"
44

5-
// sorting an array using flip operations
6-
// flip: reverse the array from 0 to i
7-
func PancakeSort[T constraints.Ordered](arr []T) []T {
5+
// Pancake sorts a slice using flip operations,
6+
// where flip refers to the idea of reversing the
7+
// slice from index `0` to `I`.
8+
func Pancake[T constraints.Ordered](arr []T) []T {
89
// early return if the array too small
910
if len(arr) <= 1 {
1011
return arr
@@ -33,7 +34,7 @@ func PancakeSort[T constraints.Ordered](arr []T) []T {
3334
return arr
3435
}
3536

36-
// reverses arr from 0 to i
37+
// flip reverses the input slice from `0` to `I`.
3738
func flip[T constraints.Ordered](arr []T, i int) []T {
3839
for j := 0; j < i; j++ {
3940
arr[j], arr[i] = arr[i], arr[j]

sort/sorts_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func TestBubble(t *testing.T) {
8282
}
8383

8484
func TestBucketSort(t *testing.T) {
85-
testFramework(t, sort.BucketSort[int])
85+
testFramework(t, sort.Bucket[int])
8686
}
8787

8888
func TestExchange(t *testing.T) {
@@ -158,7 +158,7 @@ func TestComb(t *testing.T) {
158158
}
159159

160160
func TestPancakeSort(t *testing.T) {
161-
testFramework(t, sort.PancakeSort[int])
161+
testFramework(t, sort.Pancake[int])
162162
}
163163

164164
func TestPigeonhole(t *testing.T) {
@@ -215,7 +215,7 @@ func BenchmarkBubble(b *testing.B) {
215215
}
216216

217217
func BenchmarkBucketSort(b *testing.B) {
218-
benchmarkFramework(b, sort.BucketSort[int])
218+
benchmarkFramework(b, sort.Bucket[int])
219219
}
220220

221221
func BenchmarkExchange(b *testing.B) {
@@ -276,7 +276,7 @@ func BenchmarkComb(b *testing.B) {
276276
}
277277

278278
func BenchmarkPancakeSort(b *testing.B) {
279-
benchmarkFramework(b, sort.PancakeSort[int])
279+
benchmarkFramework(b, sort.Pancake[int])
280280
}
281281

282282
func BenchmarkPigeonhole(b *testing.B) {
@@ -285,4 +285,4 @@ func BenchmarkPigeonhole(b *testing.B) {
285285

286286
func BenchmarkPatience(b *testing.B) {
287287
benchmarkFramework(b, sort.Patience[int])
288-
}
288+
}

0 commit comments

Comments
 (0)