mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-17 03:02:28 +08:00
fix: fix some spell mistake
This commit is contained in:
@@ -234,7 +234,7 @@ func (link *DoublyLink[T]) IsEmpty() bool {
|
|||||||
return link.length == 0
|
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() {
|
func (link *DoublyLink[T]) Clear() {
|
||||||
link.Head = nil
|
link.Head = nil
|
||||||
link.length = 0
|
link.length = 0
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ func (link *SinglyLink[T]) IsEmpty() bool {
|
|||||||
return link.length == 0
|
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() {
|
func (link *SinglyLink[T]) Clear() {
|
||||||
link.Head = nil
|
link.Head = nil
|
||||||
link.length = 0
|
link.length = 0
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ func (l *List[T]) DeleteAt(index int) {
|
|||||||
l.data = data
|
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) {
|
func (l *List[T]) UpdateAt(index int, value T) {
|
||||||
data := l.data
|
data := l.data
|
||||||
size := len(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:]...)...)
|
l.data = append(data[:index], append([]T{value}, data[index+1:]...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EqutalTo compare list to other list, use reflect.DeepEqual
|
// Equtal compare list to other list, use reflect.DeepEqual
|
||||||
func (l *List[T]) EqutalTo(other *List[T]) bool {
|
func (l *List[T]) Equtal(other *List[T]) bool {
|
||||||
if len(l.data) != len(other.data) {
|
if len(l.data) != len(other.data) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,15 +155,15 @@ func TestUpdateAt(t *testing.T) {
|
|||||||
assert.Equal([]int{5, 2, 3, 1}, list.Data())
|
assert.Equal([]int{5, 2, 3, 1}, list.Data())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEqutalTo(t *testing.T) {
|
func TestEqutal(t *testing.T) {
|
||||||
assert := internal.NewAssert(t, "TestEqutalTo")
|
assert := internal.NewAssert(t, "TestEqutal")
|
||||||
|
|
||||||
list1 := NewList([]int{1, 2, 3, 4})
|
list1 := NewList([]int{1, 2, 3, 4})
|
||||||
list2 := NewList([]int{1, 2, 3, 4})
|
list2 := NewList([]int{1, 2, 3, 4})
|
||||||
list3 := NewList([]int{1, 2, 3})
|
list3 := NewList([]int{1, 2, 3})
|
||||||
|
|
||||||
assert.Equal(true, list1.EqutalTo(list2))
|
assert.Equal(true, list1.Equtal(list2))
|
||||||
assert.Equal(false, list1.EqutalTo(list3))
|
assert.Equal(false, list1.Equtal(list3))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIsEmpty(t *testing.T) {
|
func TestIsEmpty(t *testing.T) {
|
||||||
@@ -192,7 +192,7 @@ func TestClone(t *testing.T) {
|
|||||||
list1 := NewList([]int{1, 2, 3, 4})
|
list1 := NewList([]int{1, 2, 3, 4})
|
||||||
list2 := list1.Clone()
|
list2 := list1.Clone()
|
||||||
|
|
||||||
assert.Equal(true, list1.EqutalTo(list2))
|
assert.Equal(true, list1.Equtal(list2))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMerge(t *testing.T) {
|
func TestMerge(t *testing.T) {
|
||||||
@@ -203,7 +203,7 @@ func TestMerge(t *testing.T) {
|
|||||||
expected := NewList([]int{1, 2, 3, 4, 4, 5, 6})
|
expected := NewList([]int{1, 2, 3, 4, 4, 5, 6})
|
||||||
|
|
||||||
list3 := list1.Merge(list2)
|
list3 := list1.Merge(list2)
|
||||||
assert.Equal(true, expected.EqutalTo(list3))
|
assert.Equal(true, expected.Equtal(list3))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSize(t *testing.T) {
|
func TestSize(t *testing.T) {
|
||||||
@@ -224,7 +224,7 @@ func TestSwap(t *testing.T) {
|
|||||||
|
|
||||||
list.Swap(0, 3)
|
list.Swap(0, 3)
|
||||||
|
|
||||||
assert.Equal(true, expected.EqutalTo(list))
|
assert.Equal(true, expected.Equtal(list))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReverse(t *testing.T) {
|
func TestReverse(t *testing.T) {
|
||||||
@@ -235,7 +235,7 @@ func TestReverse(t *testing.T) {
|
|||||||
|
|
||||||
list.Reverse()
|
list.Reverse()
|
||||||
|
|
||||||
assert.Equal(true, expected.EqutalTo(list))
|
assert.Equal(true, expected.Equtal(list))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnique(t *testing.T) {
|
func TestUnique(t *testing.T) {
|
||||||
@@ -246,7 +246,7 @@ func TestUnique(t *testing.T) {
|
|||||||
|
|
||||||
list.Unique()
|
list.Unique()
|
||||||
|
|
||||||
assert.Equal(true, expected.EqutalTo(list))
|
assert.Equal(true, expected.Equtal(list))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnion(t *testing.T) {
|
func TestUnion(t *testing.T) {
|
||||||
@@ -257,7 +257,7 @@ func TestUnion(t *testing.T) {
|
|||||||
expected := NewList([]int{1, 2, 3, 4, 5, 6})
|
expected := NewList([]int{1, 2, 3, 4, 5, 6})
|
||||||
|
|
||||||
list3 := list1.Union(list2)
|
list3 := list1.Union(list2)
|
||||||
assert.Equal(true, expected.EqutalTo(list3))
|
assert.Equal(true, expected.Equtal(list3))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntersection(t *testing.T) {
|
func TestIntersection(t *testing.T) {
|
||||||
@@ -268,5 +268,5 @@ func TestIntersection(t *testing.T) {
|
|||||||
expected := NewList([]int{4})
|
expected := NewList([]int{4})
|
||||||
|
|
||||||
list3 := list1.Intersection(list2)
|
list3 := list1.Intersection(list2)
|
||||||
assert.Equal(true, expected.EqutalTo(list3))
|
assert.Equal(true, expected.Equtal(list3))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ func (q *LinkedQueue[T]) Clear() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Print all nodes info of queue link
|
// Print all nodes info of queue link
|
||||||
func (s *LinkedQueue[T]) Print() {
|
func (q *LinkedQueue[T]) Print() {
|
||||||
current := s.head
|
current := q.head
|
||||||
info := "[ "
|
info := "[ "
|
||||||
for current != nil {
|
for current != nil {
|
||||||
info += fmt.Sprintf("%+v, ", current)
|
info += fmt.Sprintf("%+v, ", current)
|
||||||
|
|||||||
Reference in New Issue
Block a user