array_stack_test

2022-12-14 浏览 (776)

array_stack_test.go 源码

package array_stack

import (
	"fmt"
	"testing"
)

func TestArrayStack(t *testing.T) {
	stack := Default()

	stack.Push(1)
	stack.Push(23)
	stack.Push(3)
	stack.Push("jack")

	peek, _ := stack.Peek()
	fmt.Println(peek)

	fmt.Println(len(stack.data))
	fmt.Println(cap(stack.data))
	fmt.Println(stack.Size())

	stack.PrintData()

	pop, _ := stack.Pop()
	pop, _ = stack.Pop()
	pop, _ = stack.Pop()
	fmt.Println(pop)
	fmt.Println(stack.Size())

	stack.PrintData()

	pop, _ = stack.Pop()
	fmt.Println(pop)
	fmt.Println(stack.Size())
	fmt.Println(stack.Empty())
}

你可能感兴趣的文章

array_stack

  • 所属分类: 后端技术
  • 本文标签: 技术
  • 版权声明: 本文链接 https://seaxiang.com/blog/36459a23f851486b87a31246e663118e