diff --git a/impl_queue_array.go b/impl_queue_array.go index de1a399..ed6f605 100644 --- a/impl_queue_array.go +++ b/impl_queue_array.go @@ -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)), + } } diff --git a/impl_queue_linked_list.go b/impl_queue_linked_list.go index e500260..9fbb5fa 100644 --- a/impl_queue_linked_list.go +++ b/impl_queue_linked_list.go @@ -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]()), + } } diff --git a/impl_stack_array.go b/impl_stack_array.go index 13fbd2a..bdc7745 100644 --- a/impl_stack_array.go +++ b/impl_stack_array.go @@ -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)), + } } diff --git a/impl_stack_linked_list.go b/impl_stack_linked_list.go index 46698a9..cfbe572 100644 --- a/impl_stack_linked_list.go +++ b/impl_stack_linked_list.go @@ -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]()), + } } diff --git a/int_map.go b/int_map.go index 0ffdd02..85ad324 100644 --- a/int_map.go +++ b/int_map.go @@ -1 +1,2 @@ +package ds // TODO \ No newline at end of file diff --git a/int_tree.go b/int_tree.go index 0ffdd02..85ad324 100644 --- a/int_tree.go +++ b/int_tree.go @@ -1 +1,2 @@ +package ds // TODO \ No newline at end of file