stack

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

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