added Clear() method for stacks and queues

This commit is contained in:
milarin 2023-01-20 22:12:17 +01:00
parent a83a8ca68e
commit f8635b5cf2
4 changed files with 10 additions and 0 deletions

View File

@ -41,3 +41,7 @@ func (s *ListQueue[T]) Size() int {
func (s *ListQueue[T]) Empty() bool {
return s.Size() == 0
}
func (s *ListQueue[T]) Clear() {
s.list.Clear()
}

View File

@ -41,3 +41,7 @@ func (s *ListStack[T]) Size() int {
func (s *ListStack[T]) Empty() bool {
return s.Size() == 0
}
func (s *ListStack[T]) Clear() {
s.list.Clear()
}

View File

@ -3,6 +3,7 @@ package ds
type Queue[T any] interface {
Addable[T]
Sized
Clearable
Enqueue(value T)
Dequeue() T

View File

@ -3,6 +3,7 @@ package ds
type Stack[T any] interface {
Addable[T]
Sized
Clearable
Push(value T)
Pop() T