fix(go): modify interface of stack, queue and deque

This commit is contained in:
reanon
2022-11-29 10:42:09 +08:00
parent d32f15feb1
commit 19469aecbf
7 changed files with 32 additions and 27 deletions

View File

@@ -7,8 +7,9 @@ package chapter_stack_and_queue
import "testing"
func TestArrayStack(t *testing.T) {
// 初始化栈
stack := NewArrayStack()
// 初始化栈, 使用接口承接
var stack Stack
stack = NewArrayStack()
// 元素入栈
stack.Push(1)
@@ -37,8 +38,8 @@ func TestArrayStack(t *testing.T) {
func TestLinkedListStack(t *testing.T) {
// 初始化栈
stack := NewLinkedListStack()
var stack Stack
stack = NewLinkedListStack()
// 元素入栈
stack.Push(1)
stack.Push(2)