impemented stacks and queues
This commit is contained in:
parent
7dc44b9cd2
commit
a83a8ca68e
@ -1,8 +1,13 @@
|
||||
package ds
|
||||
|
||||
type ArrayQueue[T any] ListQueue[T]
|
||||
type ArrayQueue[T any] struct {
|
||||
*ListQueue[T]
|
||||
}
|
||||
|
||||
var _ Queue[int] = &ArrayQueue[int]{}
|
||||
|
||||
func NewArrayQueue[T any]() *ArrayQueue[T] {
|
||||
stack := NewListQueue[T](new(ArrayList[T]))
|
||||
return (*ArrayQueue[T])(stack)
|
||||
return &ArrayQueue[T]{
|
||||
ListQueue: NewListQueue[T](NewArrayList[T](0)),
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,13 @@
|
||||
package ds
|
||||
|
||||
type LinkedListQueue[T any] ListQueue[T]
|
||||
type LinkedListQueue[T any] struct {
|
||||
*ListQueue[T]
|
||||
}
|
||||
|
||||
var _ Queue[int] = &LinkedListQueue[int]{}
|
||||
|
||||
func NewLinkedListQueue[T any]() *LinkedListQueue[T] {
|
||||
stack := NewListQueue[T](new(LinkedList[T]))
|
||||
return (*LinkedListQueue[T])(stack)
|
||||
return &LinkedListQueue[T]{
|
||||
ListQueue: NewListQueue[T](NewLinkedList[T]()),
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,13 @@
|
||||
package ds
|
||||
|
||||
type ArrayStack[T any] ListStack[T]
|
||||
type ArrayStack[T any] struct {
|
||||
*ListStack[T]
|
||||
}
|
||||
|
||||
var _ Stack[int] = &ArrayStack[int]{}
|
||||
|
||||
func NewArrayStack[T any]() *ArrayStack[T] {
|
||||
stack := NewListStack[T](new(ArrayList[T]))
|
||||
return (*ArrayStack[T])(stack)
|
||||
return &ArrayStack[T]{
|
||||
ListStack: NewListStack[T](NewArrayList[T](0)),
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,13 @@
|
||||
package ds
|
||||
|
||||
type LinkedListStack[T any] ListStack[T]
|
||||
|
||||
func NewLinkedListStack[T any]() *ArrayStack[T] {
|
||||
stack := NewListStack[T](new(LinkedList[T]))
|
||||
return (*ArrayStack[T])(stack)
|
||||
type LinkedListStack[T any] struct {
|
||||
*ListStack[T]
|
||||
}
|
||||
|
||||
var _ Stack[int] = &LinkedListStack[int]{}
|
||||
|
||||
func NewLinkedListStack[T any]() *LinkedListStack[T] {
|
||||
return &LinkedListStack[T]{
|
||||
ListStack: NewListStack[T](NewLinkedList[T]()),
|
||||
}
|
||||
}
|
||||
|
@ -1 +1,2 @@
|
||||
package ds
|
||||
// TODO
|
@ -1 +1,2 @@
|
||||
package ds
|
||||
// TODO
|
Loading…
Reference in New Issue
Block a user