stack

package
v0.0.0-...-9a4132b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayStack

type ArrayStack struct {
	// contains filtered or unexported fields
}

构建 ArrayStack 结构,并实现 Stack 接口

func NewArrayStack

func NewArrayStack() *ArrayStack

func (*ArrayStack) GetSize

func (a *ArrayStack) GetSize() int

func (*ArrayStack) IsEmpty

func (a *ArrayStack) IsEmpty() bool

func (*ArrayStack) Peek

func (a *ArrayStack) Peek() interface{}

func (*ArrayStack) Pop

func (a *ArrayStack) Pop() interface{}

func (*ArrayStack) Push

func (a *ArrayStack) Push(e interface{})

type Stack

type Stack interface {
	// 判断栈是否为空
	IsEmpty() bool
	// 获取栈大小
	GetSize() int
	// 元素入栈
	Push(e interface{})
	// 元素出栈
	Pop() interface{}
	// 查看栈顶元素
	Peek() interface{}
}

栈是一个 FILO(先进后出)的数据结构

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL