diff --git a/queue.go b/queue.go index c1081ec2..a6945caf 100644 --- a/queue.go +++ b/queue.go @@ -3,8 +3,6 @@ package sctp -import "fmt" - type queue[T any] struct { buf []T head int @@ -37,9 +35,6 @@ func (q *queue[T]) PushBack(ele T) { } func (q *queue[T]) PopFront() T { - if q.count <= 0 { - panic("PopFront() called on empty queue") - } ele := q.buf[q.head] var zeroVal T q.buf[q.head] = zeroVal @@ -49,16 +44,10 @@ func (q *queue[T]) PopFront() T { } func (q *queue[T]) Front() T { - if q.count <= 0 { - panic("Front() called on empty queue") - } return q.buf[q.head] } func (q *queue[T]) At(i int) T { - if i < 0 || i >= q.count { - panic(fmt.Sprintf("index %d out of range %d", i, q.count)) - } return q.buf[(q.head+i)%(len(q.buf))] } diff --git a/queue_test.go b/queue_test.go index 676ab9c1..7a19230f 100644 --- a/queue_test.go +++ b/queue_test.go @@ -11,8 +11,6 @@ import ( func TestQueue(t *testing.T) { q := newQueue[int](32) - assert.Panics(t, func() { q.PopFront() }) - assert.Panics(t, func() { q.Front() }) assert.Zero(t, q.Len()) // test push & pop @@ -32,9 +30,6 @@ func TestQueue(t *testing.T) { assert.Equal(t, 2, q.Len()) assert.Equal(t, 11, q.At(1)) assert.Equal(t, 10, q.Front()) - assert.Panics(t, func() { - q.At(33) - }) assert.Equal(t, 10, q.PopFront()) assert.Equal(t, 11, q.PopFront())