pipe

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: Apache-2.0, BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const Infinity = 0

Variables

This section is empty.

Functions

This section is empty.

Types

type Hashable

type Hashable interface {
	GetHash() hashing.HashValue
}

type InfinitePipe

type InfinitePipe 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) Close

func (ch *InfinitePipe) Close()

func (*InfinitePipe) In

func (ch *InfinitePipe) In() chan<- interface{}

func (*InfinitePipe) Len

func (ch *InfinitePipe) Len() int

func (*InfinitePipe) Out

func (ch *InfinitePipe) Out() <-chan interface{}

type LimitedPriorityHashQueue

type LimitedPriorityHashQueue struct {
	// contains filtered or unexported fields
}

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

func (*LimitedPriorityHashQueue) Add

func (q *LimitedPriorityHashQueue) Add(elem interface{}) 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) Get

func (q *LimitedPriorityHashQueue) Get(i int) interface{}

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) Length

func (q *LimitedPriorityHashQueue) Length() int

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

func (*LimitedPriorityHashQueue) Peek

func (q *LimitedPriorityHashQueue) Peek() interface{}

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

func (*LimitedPriorityHashQueue) Remove

func (q *LimitedPriorityHashQueue) Remove() interface{}

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 interface {
	In() chan<- interface{}
	Out() <-chan interface{}
	Len() int
	Close()
}

func NewDefaultInfinitePipe

func NewDefaultInfinitePipe() Pipe

func NewHashInfinitePipe

func NewHashInfinitePipe() Pipe

func NewInfinitePipe

func NewInfinitePipe(priorityFun func(interface{}) bool, limit int) Pipe

func NewLimitHashInfinitePipe

func NewLimitHashInfinitePipe(limit int) Pipe

func NewLimitInfinitePipe

func NewLimitInfinitePipe(limit int) Pipe

func NewLimitPriorityInfinitePipe

func NewLimitPriorityInfinitePipe(priorityFun func(interface{}) bool, limit int) Pipe

func NewPriorityHashInfinitePipe

func NewPriorityHashInfinitePipe(priorityFun func(interface{}) bool) Pipe

func NewPriorityInfinitePipe

func NewPriorityInfinitePipe(priorityFun func(interface{}) bool) Pipe

type Queue

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

func NewDefaultLimitedPriorityHashQueue

func NewDefaultLimitedPriorityHashQueue() Queue

func NewHashLimitedPriorityHashQueue

func NewHashLimitedPriorityHashQueue(hashNeeded bool) Queue

func NewLimitHashLimitedPriorityHashQueue

func NewLimitHashLimitedPriorityHashQueue(limit int, hashNeeded bool) Queue

func NewLimitLimitedPriorityHashQueue

func NewLimitLimitedPriorityHashQueue(limit int) Queue

func NewLimitPriorityLimitedPriorityHashQueue

func NewLimitPriorityLimitedPriorityHashQueue(priorityFun func(interface{}) bool, limit int) Queue

func NewLimitedPriorityHashQueue

func NewLimitedPriorityHashQueue(priorityFun func(interface{}) bool, limit int, hashNeeded bool) Queue

func NewPriorityHashLimitedPriorityHashQueue

func NewPriorityHashLimitedPriorityHashQueue(priorityFun func(interface{}) bool, hashNeeded bool) Queue

func NewPriorityLimitedPriorityHashQueue

func NewPriorityLimitedPriorityHashQueue(priorityFun func(interface{}) bool) Queue

type SimpleHashable

type SimpleHashable int

func (SimpleHashable) GetHash

func (sh SimpleHashable) GetHash() hashing.HashValue

Jump to

Keyboard shortcuts

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