Stack

package
v0.0.0-...-f9b1802 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 1 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[T any] struct {
	// contains filtered or unexported fields
}

func NewArrayStack

func NewArrayStack[T any](cap int) *ArrayStack[T]

func (ArrayStack[T]) IsEmpty

func (a ArrayStack[T]) IsEmpty() bool

func (ArrayStack[T]) Peek

func (a ArrayStack[T]) Peek() (T, error)

func (ArrayStack[T]) Pop

func (a ArrayStack[T]) Pop() (T, error)

弹出栈顶元素

func (ArrayStack[T]) Push

func (a ArrayStack[T]) Push(t T)

压栈

func (*ArrayStack[T]) Size

func (a *ArrayStack[T]) Size() int

type LinkedStack

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

func NewLinkedStack

func NewLinkedStack[T any]() *LinkedStack[T]

func (*LinkedStack[T]) IsEmpty

func (l *LinkedStack[T]) IsEmpty() bool

func (*LinkedStack[T]) Peek

func (l *LinkedStack[T]) Peek() (T, error)

func (LinkedStack[T]) Pop

func (l LinkedStack[T]) Pop() (T, error)

func (*LinkedStack[T]) Push

func (l *LinkedStack[T]) Push(t T)

func (*LinkedStack[T]) Size

func (l *LinkedStack[T]) Size() int

type Stack

type Stack[T any] interface {
	Size() int

	IsEmpty() bool

	Peek() (T, error)

	Push(T)

	Pop() (T, error)
}

Jump to

Keyboard shortcuts

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