pipe

package
v1.2.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NoPriority added in v1.0.3

func NoPriority[E any](E) bool

Types

type Deque added in v1.0.3

type Deque[E any] interface {
	Length() int
	AddStart(elem E) bool
	AddEnd(elem E) bool
	PeekStart() E
	PeekEnd() E
	PeekNStart(n int) []E
	PeekNEnd(n int) []E
	PeekAll() []E
	Get(i int) E
	RemoveStart() E
	RemoveEnd() E
	RemoveAt(i int) E
}

func NewDeque added in v1.0.3

func NewDeque[E any]() Deque[E]

NewDeque creates an unlimited deque

func NewLimitedDeque added in v1.0.3

func NewLimitedDeque[E any](limit int) Deque[E]

NewLimitedDeque creates a deque, which cannot grow above `limit` elements

type Factory added in v1.0.3

type Factory[E IntConvertible] interface {
	Create(int) E
}

func NewSimpleHashableFactory added in v1.0.3

func NewSimpleHashableFactory() Factory[SimpleHashable]

func NewSimpleNothashableFactory added in v1.0.3

func NewSimpleNothashableFactory() Factory[SimpleNothashable]

type Hashable

type Hashable interface {
	GetHash() hashing.HashValue
}

type InfinitePipe

type InfinitePipe[E any] struct {
	// contains filtered or unexported fields
}

InfinitePipe provides deserialised sender and receiver: it queues messages sent by the sender and returns them to the receiver whenever it is ready, without blocking the sender process. Depending on the backing queue, the pipe might have other characteristics.

func (*InfinitePipe[E]) Close

func (ch *InfinitePipe[E]) Close()

func (*InfinitePipe[E]) Discard added in v1.0.3

func (ch *InfinitePipe[E]) Discard()

func (*InfinitePipe[E]) In

func (ch *InfinitePipe[E]) In() chan<- E

func (*InfinitePipe[E]) Len

func (ch *InfinitePipe[E]) Len() int

func (*InfinitePipe[E]) Out

func (ch *InfinitePipe[E]) Out() <-chan E

func (*InfinitePipe[E]) TryAdd added in v1.0.3

func (ch *InfinitePipe[E]) TryAdd(e E, log func(msg string, args ...interface{}))

type IntConvertible added in v1.0.3

type IntConvertible interface {
	AsInt() int
}

type LimitedPriorityHashQueue

type LimitedPriorityHashQueue[E any] struct {
	// contains filtered or unexported fields
}

LimitedPriorityHashQueue is a queue, which can prioritize elements, limit its growth and reject already included elements.

func (*LimitedPriorityHashQueue[E]) Add

func (q *LimitedPriorityHashQueue[E]) Add(elem E) bool

Add puts an element to the start or end of the queue, depending on the result of priorityFun. If the limited queue is full it adds a new element removing the previously added element, according to the following rules:

  • not prioritized element is chosen for deletion, if possible
  • the chosen for deletion element is always the oldest among its type
  • not prioritized element can not be added if there are no not prioritized elements to delete

If it is a hash queue, the element is not added, if it is already in the queue. If the add was successful, returns `true`.

func (*LimitedPriorityHashQueue[E]) Get

func (q *LimitedPriorityHashQueue[E]) Get(i int) E

Get returns the element at index i in the queue. If the index is invalid, the call will panic. This method accepts both positive and negative index values. Index 0 refers to the first element, and index -1 refers to the last.

func (*LimitedPriorityHashQueue[E]) Length

func (q *LimitedPriorityHashQueue[E]) Length() int

Length returns the number of elements currently stored in the queue.

func (*LimitedPriorityHashQueue[E]) Peek

func (q *LimitedPriorityHashQueue[E]) Peek() E

Peek returns the element at the head of the queue. This call panics if the queue is empty.

func (*LimitedPriorityHashQueue[E]) Remove

func (q *LimitedPriorityHashQueue[E]) Remove() E

Remove removes and returns the element from the front of the queue. If the queue is empty, the call will panic.

type Pipe

type Pipe[E any] interface {
	In() chan<- E
	Out() <-chan E
	Len() int
	Close()
	Discard()
	TryAdd(e E, log func(msg string, args ...interface{}))
}

func NewHashInfinitePipe

func NewHashInfinitePipe[E Hashable]() Pipe[E]

func NewInfinitePipe

func NewInfinitePipe[E any]() Pipe[E]

func NewLimitHashInfinitePipe

func NewLimitHashInfinitePipe[E Hashable](limit int) Pipe[E]

func NewLimitInfinitePipe

func NewLimitInfinitePipe[E any](limit int) Pipe[E]

func NewLimitPriorityHashInfinitePipe added in v1.0.3

func NewLimitPriorityHashInfinitePipe[E Hashable](priorityFun func(E) bool, limit int) Pipe[E]

func NewLimitPriorityInfinitePipe

func NewLimitPriorityInfinitePipe[E any](priorityFun func(E) bool, limit int) Pipe[E]

func NewPriorityHashInfinitePipe

func NewPriorityHashInfinitePipe[E Hashable](priorityFun func(E) bool) Pipe[E]

func NewPriorityInfinitePipe

func NewPriorityInfinitePipe[E any](priorityFun func(E) bool) Pipe[E]

type Queue

type Queue[E any] interface {
	Length() int
	Add(elem E) bool
	Peek() E
	Get(i int) E
	Remove() E
}

func NewHashLimitedPriorityHashQueue

func NewHashLimitedPriorityHashQueue[E Hashable]() Queue[E]

func NewLimitHashLimitedPriorityHashQueue

func NewLimitHashLimitedPriorityHashQueue[E Hashable](limit int) Queue[E]

func NewLimitLimitedPriorityHashQueue

func NewLimitLimitedPriorityHashQueue[E any](limit int) Queue[E]

func NewLimitPriorityHashLimitedPriorityHashQueue added in v1.0.3

func NewLimitPriorityHashLimitedPriorityHashQueue[E Hashable](priorityFun func(E) bool, limit int) Queue[E]

func NewLimitPriorityLimitedPriorityHashQueue

func NewLimitPriorityLimitedPriorityHashQueue[E any](priorityFun func(E) bool, limit int) Queue[E]

func NewLimitedPriorityHashQueue

func NewLimitedPriorityHashQueue[E any]() Queue[E]

func NewPriorityHashLimitedPriorityHashQueue

func NewPriorityHashLimitedPriorityHashQueue[E Hashable](priorityFun func(E) bool) Queue[E]

func NewPriorityLimitedPriorityHashQueue

func NewPriorityLimitedPriorityHashQueue[E any](priorityFun func(E) bool) Queue[E]

type SimpleHashable

type SimpleHashable int

func (SimpleHashable) AsInt added in v1.0.3

func (sh SimpleHashable) AsInt() int

func (SimpleHashable) GetHash

func (sh SimpleHashable) GetHash() hashing.HashValue

type SimpleHashableFactory added in v1.0.3

type SimpleHashableFactory struct{}

func (*SimpleHashableFactory) Create added in v1.0.3

type SimpleNothashable added in v1.0.3

type SimpleNothashable int

func (SimpleNothashable) AsInt added in v1.0.3

func (snh SimpleNothashable) AsInt() int

type SimpleNothashableFactory added in v1.0.3

type SimpleNothashableFactory struct{}

func (*SimpleNothashableFactory) Create added in v1.0.3

Jump to

Keyboard shortcuts

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