Documentation ¶
Index ¶
- func NoPriority[E any](E) bool
- type Deque
- type Factory
- type Hashable
- type InfinitePipe
- type IntConvertible
- type LimitedPriorityHashQueue
- type Pipe
- func NewHashInfinitePipe[E Hashable]() Pipe[E]
- func NewInfinitePipe[E any]() Pipe[E]
- func NewLimitHashInfinitePipe[E Hashable](limit int) Pipe[E]
- func NewLimitInfinitePipe[E any](limit int) Pipe[E]
- func NewLimitPriorityHashInfinitePipe[E Hashable](priorityFun func(E) bool, limit int) Pipe[E]
- func NewLimitPriorityInfinitePipe[E any](priorityFun func(E) bool, limit int) Pipe[E]
- func NewPriorityHashInfinitePipe[E Hashable](priorityFun func(E) bool) Pipe[E]
- func NewPriorityInfinitePipe[E any](priorityFun func(E) bool) Pipe[E]
- type Queue
- func NewHashLimitedPriorityHashQueue[E Hashable]() Queue[E]
- func NewLimitHashLimitedPriorityHashQueue[E Hashable](limit int) Queue[E]
- func NewLimitLimitedPriorityHashQueue[E any](limit int) Queue[E]
- func NewLimitPriorityHashLimitedPriorityHashQueue[E Hashable](priorityFun func(E) bool, limit int) Queue[E]
- func NewLimitPriorityLimitedPriorityHashQueue[E any](priorityFun func(E) bool, limit int) Queue[E]
- func NewLimitedPriorityHashQueue[E any]() Queue[E]
- func NewPriorityHashLimitedPriorityHashQueue[E Hashable](priorityFun func(E) bool) Queue[E]
- func NewPriorityLimitedPriorityHashQueue[E any](priorityFun func(E) bool) Queue[E]
- type SimpleHashable
- type SimpleHashableFactory
- type SimpleNothashable
- type SimpleNothashableFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NoPriority ¶ added in v1.0.3
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 NewLimitedDeque ¶ added in v1.0.3
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 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 NewInfinitePipe ¶
func NewLimitInfinitePipe ¶
func NewLimitPriorityHashInfinitePipe ¶ added in v1.0.3
func NewPriorityInfinitePipe ¶
type Queue ¶
func NewLimitPriorityHashLimitedPriorityHashQueue ¶ added in v1.0.3
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
func (*SimpleHashableFactory) Create(i int) SimpleHashable
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
func (*SimpleNothashableFactory) Create(i int) SimpleNothashable