atomicStack

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

README

栈操作 先入后出

未经实际使用

package main
func main() {
	stk := NewAtomicStack[int]()
	go stk.Push(1)
	go stk.Push(2)
	go stk.Push(3)
	go stk.Push(4)

	time.Sleep(time.Second * 1)

	fmt.Println(*stk.Pop())
	fmt.Println(*stk.Pop())
	fmt.Println(*stk.Pop())
	fmt.Println(*stk.Pop())
	fmt.Println(*stk.Pop())
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicStack

type AtomicStack[V any] struct {
	// contains filtered or unexported fields
}

AtomicStack 栈顶指针

func NewAtomicStack

func NewAtomicStack[V any]() *AtomicStack[V]

NewAtomicStack 初始化一个栈 并将栈顶设置为空

func (*AtomicStack[V]) Pop

func (s *AtomicStack[V]) Pop() *V

Pop 出栈

func (*AtomicStack[V]) Push

func (s *AtomicStack[V]) Push(val V)

Push 入栈

Jump to

Keyboard shortcuts

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