stack

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New[Value any](opts ...options.Option[core.Options]) core.Stack[Value]

New creates a new lock-free stack.

func NewQueueAdapter

func NewQueueAdapter[T any](capacity int) core.Queue[T]

Types

type LLStack

type LLStack[Value any] struct {
	// contains filtered or unexported fields
}

LLStack is a lock-free stack implemented with linked list, based on atomic compare-and-swap operations.

func (*LLStack[Value]) Empty

func (s *LLStack[Value]) Empty() bool

Len returns the number of items in the stack.

func (*LLStack[Value]) Full

func (s *LLStack[Value]) Full() bool

Len returns the number of items in the stack.

func (*LLStack[Value]) Pop

func (s *LLStack[Value]) Pop() (Value, bool)

Pop removes the next value from the stack.

func (*LLStack[Value]) Push

func (s *LLStack[Value]) Push(value Value) bool

Push adds a new value to the stack. It keeps retrying in case of conflict with concurrent Pop()/Push() operations.

func (*LLStack[Value]) Range

func (s *LLStack[Value]) Range(iterator func(val Value) bool)

Range iterates over the stack, accepts a custom iterator that returns true to stop.

func (*LLStack[Value]) Size

func (s *LLStack[Value]) Size() int

Size returns the number of items in the stack.

type QueueAdapter

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

func (*QueueAdapter[T]) Dequeue

func (q *QueueAdapter[T]) Dequeue() (T, bool)

func (*QueueAdapter[T]) Empty

func (q *QueueAdapter[T]) Empty() bool

func (*QueueAdapter[T]) Enqueue

func (q *QueueAdapter[T]) Enqueue(v T) bool

func (*QueueAdapter[T]) Full

func (q *QueueAdapter[T]) Full() bool

func (*QueueAdapter[T]) Size

func (q *QueueAdapter[T]) Size() int

Jump to

Keyboard shortcuts

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