1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

refactor: change func Length to Size in CircularQueue

This commit is contained in:
dudaodong
2022-06-05 16:57:03 +08:00
parent 747dc30b02
commit 61251fb0f1
2 changed files with 7 additions and 7 deletions

View File

@@ -37,8 +37,8 @@ func (q *CircularQueue[T]) Data() []T {
return data
}
// Length return current data length of queue
func (q *CircularQueue[T]) Length() int {
// Size return number of elements in circular queue
func (q *CircularQueue[T]) Size() int {
if q.capacity == 0 {
return 0
}

View File

@@ -18,7 +18,7 @@ func TestCircularQueue_Enqueue(t *testing.T) {
queue.Print()
assert.Equal([]int{1, 2, 3, 4, 5}, queue.Data())
assert.Equal(5, queue.Length())
assert.Equal(5, queue.Size())
err := queue.Enqueue(6)
assert.IsNotNil(err)
@@ -72,7 +72,7 @@ func TestCircularQueue_Front(t *testing.T) {
val := queue.Front()
assert.Equal(3, val)
assert.Equal(5, queue.Length())
assert.Equal(5, queue.Size())
}
func TestCircularQueue_Back(t *testing.T) {
@@ -113,15 +113,15 @@ func TestCircularQueue_Clear(t *testing.T) {
queue := NewCircularQueue[int](3)
assert.Equal(true, queue.IsEmpty())
assert.Equal(0, queue.Length())
assert.Equal(0, queue.Size())
queue.Enqueue(1)
assert.Equal(false, queue.IsEmpty())
assert.Equal(1, queue.Length())
assert.Equal(1, queue.Size())
queue.Clear()
assert.Equal(true, queue.IsEmpty())
assert.Equal(0, queue.Length())
assert.Equal(0, queue.Size())
}
func TestCircularQueue_Data(t *testing.T) {