added Clear() method for stacks and queues
This commit is contained in:
parent
a83a8ca68e
commit
f8635b5cf2
@ -41,3 +41,7 @@ func (s *ListQueue[T]) Size() int {
|
|||||||
func (s *ListQueue[T]) Empty() bool {
|
func (s *ListQueue[T]) Empty() bool {
|
||||||
return s.Size() == 0
|
return s.Size() == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ListQueue[T]) Clear() {
|
||||||
|
s.list.Clear()
|
||||||
|
}
|
||||||
|
@ -41,3 +41,7 @@ func (s *ListStack[T]) Size() int {
|
|||||||
func (s *ListStack[T]) Empty() bool {
|
func (s *ListStack[T]) Empty() bool {
|
||||||
return s.Size() == 0
|
return s.Size() == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ListStack[T]) Clear() {
|
||||||
|
s.list.Clear()
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@ package ds
|
|||||||
type Queue[T any] interface {
|
type Queue[T any] interface {
|
||||||
Addable[T]
|
Addable[T]
|
||||||
Sized
|
Sized
|
||||||
|
Clearable
|
||||||
|
|
||||||
Enqueue(value T)
|
Enqueue(value T)
|
||||||
Dequeue() T
|
Dequeue() T
|
||||||
|
@ -3,6 +3,7 @@ package ds
|
|||||||
type Stack[T any] interface {
|
type Stack[T any] interface {
|
||||||
Addable[T]
|
Addable[T]
|
||||||
Sized
|
Sized
|
||||||
|
Clearable
|
||||||
|
|
||||||
Push(value T)
|
Push(value T)
|
||||||
Pop() T
|
Pop() T
|
||||||
|
Loading…
Reference in New Issue
Block a user