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