stack

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 0 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stack

type Stack[T any] struct {
	// contains filtered or unexported fields
}

Stack 是一个通用类型的栈结构

func (*Stack[T]) IsEmpty

func (s *Stack[T]) IsEmpty() bool

IsEmpty 检查栈是否为空

func (*Stack[T]) Peek

func (s *Stack[T]) Peek() *T

Peek 返回栈顶元素但不移除,如果栈为空则返回错误

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() *T

Pop 弹出并返回栈顶元素,如果栈为空则返回错误

func (*Stack[T]) Push

func (s *Stack[T]) Push(item *T)

Push 将元素压入栈顶

func (*Stack[T]) Size

func (s *Stack[T]) Size() int

Size 返回栈中元素的数量

Jump to

Keyboard shortcuts

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