stack

package
v0.10.8 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: MIT, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LockFreeStack added in v0.3.0

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

LockFreeStack implements lock-free freelist based stack.

Example
s := NewLockFreeStack[int]()

s.Push(1)
s.Push(2)
s.Push(3)

fmt.Println(s.Pop())
fmt.Println(s.Pop())
fmt.Println(s.Pop())
Output:

3 true
2 true
1 true

func NewLockFreeStack added in v0.3.0

func NewLockFreeStack[T any]() *LockFreeStack[T]

NewLockFreeStack creates a new lock-free queue.

func (*LockFreeStack[T]) Len added in v0.10.8

func (s *LockFreeStack[T]) Len() uint64

func (*LockFreeStack[T]) Pop added in v0.3.0

func (s *LockFreeStack[T]) Pop() (T, bool)

Pop pops value from the top of the stack.

func (*LockFreeStack[T]) Push added in v0.3.0

func (s *LockFreeStack[T]) Push(v T)

Push pushes a value on top of the stack.

type MutexStack added in v0.10.8

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

func NewMutexStack added in v0.10.8

func NewMutexStack[T any]() *MutexStack[T]

func (*MutexStack[T]) Pop added in v0.10.8

func (s *MutexStack[T]) Pop() (T, bool)

func (*MutexStack[T]) Push added in v0.10.8

func (s *MutexStack[T]) Push(v T)

Jump to

Keyboard shortcuts

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