From 48c1f8ffad6b6e314bf626e4c070e500dc5e98c1 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Sun, 13 Feb 2022 19:00:44 +0800 Subject: [PATCH] fix: fix some spell mistake --- datastructure/link/doublylink.go | 2 +- datastructure/link/singlylink.go | 2 +- datastructure/list/list.go | 6 +++--- datastructure/list/list_test.go | 22 +++++++++++----------- datastructure/queue/linkedqueue.go | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/datastructure/link/doublylink.go b/datastructure/link/doublylink.go index 09b40fd..66c29be 100644 --- a/datastructure/link/doublylink.go +++ b/datastructure/link/doublylink.go @@ -234,7 +234,7 @@ func (link *DoublyLink[T]) IsEmpty() bool { return link.length == 0 } -// IsEmpty checks if link is empty or not +// Clear checks if link is empty or not func (link *DoublyLink[T]) Clear() { link.Head = nil link.length = 0 diff --git a/datastructure/link/singlylink.go b/datastructure/link/singlylink.go index 69723d1..88d2a94 100644 --- a/datastructure/link/singlylink.go +++ b/datastructure/link/singlylink.go @@ -205,7 +205,7 @@ func (link *SinglyLink[T]) IsEmpty() bool { return link.length == 0 } -// IsEmpty checks if link is empty or not +// Clear checks if link is empty or not func (link *SinglyLink[T]) Clear() { link.Head = nil link.length = 0 diff --git a/datastructure/list/list.go b/datastructure/list/list.go index 86bf843..3730723 100644 --- a/datastructure/list/list.go +++ b/datastructure/list/list.go @@ -121,7 +121,7 @@ func (l *List[T]) DeleteAt(index int) { l.data = data } -// InsertAt insert value into list at index, index shoud between 0 and list size -1 +// UpdateAt update value of list at index, index shoud between 0 and list size -1 func (l *List[T]) UpdateAt(index int, value T) { data := l.data size := len(data) @@ -132,8 +132,8 @@ func (l *List[T]) UpdateAt(index int, value T) { l.data = append(data[:index], append([]T{value}, data[index+1:]...)...) } -// EqutalTo compare list to other list, use reflect.DeepEqual -func (l *List[T]) EqutalTo(other *List[T]) bool { +// Equtal compare list to other list, use reflect.DeepEqual +func (l *List[T]) Equtal(other *List[T]) bool { if len(l.data) != len(other.data) { return false } diff --git a/datastructure/list/list_test.go b/datastructure/list/list_test.go index 457b535..b72d8b1 100644 --- a/datastructure/list/list_test.go +++ b/datastructure/list/list_test.go @@ -155,15 +155,15 @@ func TestUpdateAt(t *testing.T) { assert.Equal([]int{5, 2, 3, 1}, list.Data()) } -func TestEqutalTo(t *testing.T) { - assert := internal.NewAssert(t, "TestEqutalTo") +func TestEqutal(t *testing.T) { + assert := internal.NewAssert(t, "TestEqutal") list1 := NewList([]int{1, 2, 3, 4}) list2 := NewList([]int{1, 2, 3, 4}) list3 := NewList([]int{1, 2, 3}) - assert.Equal(true, list1.EqutalTo(list2)) - assert.Equal(false, list1.EqutalTo(list3)) + assert.Equal(true, list1.Equtal(list2)) + assert.Equal(false, list1.Equtal(list3)) } func TestIsEmpty(t *testing.T) { @@ -192,7 +192,7 @@ func TestClone(t *testing.T) { list1 := NewList([]int{1, 2, 3, 4}) list2 := list1.Clone() - assert.Equal(true, list1.EqutalTo(list2)) + assert.Equal(true, list1.Equtal(list2)) } func TestMerge(t *testing.T) { @@ -203,7 +203,7 @@ func TestMerge(t *testing.T) { expected := NewList([]int{1, 2, 3, 4, 4, 5, 6}) list3 := list1.Merge(list2) - assert.Equal(true, expected.EqutalTo(list3)) + assert.Equal(true, expected.Equtal(list3)) } func TestSize(t *testing.T) { @@ -224,7 +224,7 @@ func TestSwap(t *testing.T) { list.Swap(0, 3) - assert.Equal(true, expected.EqutalTo(list)) + assert.Equal(true, expected.Equtal(list)) } func TestReverse(t *testing.T) { @@ -235,7 +235,7 @@ func TestReverse(t *testing.T) { list.Reverse() - assert.Equal(true, expected.EqutalTo(list)) + assert.Equal(true, expected.Equtal(list)) } func TestUnique(t *testing.T) { @@ -246,7 +246,7 @@ func TestUnique(t *testing.T) { list.Unique() - assert.Equal(true, expected.EqutalTo(list)) + assert.Equal(true, expected.Equtal(list)) } func TestUnion(t *testing.T) { @@ -257,7 +257,7 @@ func TestUnion(t *testing.T) { expected := NewList([]int{1, 2, 3, 4, 5, 6}) list3 := list1.Union(list2) - assert.Equal(true, expected.EqutalTo(list3)) + assert.Equal(true, expected.Equtal(list3)) } func TestIntersection(t *testing.T) { @@ -268,5 +268,5 @@ func TestIntersection(t *testing.T) { expected := NewList([]int{4}) list3 := list1.Intersection(list2) - assert.Equal(true, expected.EqutalTo(list3)) + assert.Equal(true, expected.Equtal(list3)) } diff --git a/datastructure/queue/linkedqueue.go b/datastructure/queue/linkedqueue.go index f979d64..6e988a3 100644 --- a/datastructure/queue/linkedqueue.go +++ b/datastructure/queue/linkedqueue.go @@ -92,8 +92,8 @@ func (q *LinkedQueue[T]) Clear() { } // Print all nodes info of queue link -func (s *LinkedQueue[T]) Print() { - current := s.head +func (q *LinkedQueue[T]) Print() { + current := q.head info := "[ " for current != nil { info += fmt.Sprintf("%+v, ", current)