stack

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Overview

Package stack 提供简单的栈数据结构实现与测试

该包实现了基本的栈操作,用于在算法或业务逻辑中临时存储数据

Package stack 提供了一个最简栈的实现(线程不安全)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stack

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

Stack 结构体表示一个栈

func New

func New() *Stack

New 创建并返回一个新的栈

func (*Stack) Bottom

func (s *Stack) Bottom() (any, bool)

Bottom 查看栈底元素(最先入栈的元素)

func (*Stack) IsEmpty

func (s *Stack) IsEmpty() bool

IsEmpty 检查栈是否为空

func (*Stack) Pop

func (s *Stack) Pop() (any, bool)

Pop 弹出栈顶元素

func (*Stack) Push

func (s *Stack) Push(item any)

Push 将元素压入栈顶

func (*Stack) Size

func (s *Stack) Size() int

Size 返回栈中元素的数量

func (*Stack) Top

func (s *Stack) Top() (any, bool)

Top 查看栈顶元素但不移除

Jump to

Keyboard shortcuts

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