Documentation ¶
Index ¶
- Constants
- type Hashable
- type InfinitePipe
- type LimitedPriorityHashQueue
- type Pipe
- func NewDefaultInfinitePipe() Pipe
- func NewHashInfinitePipe() Pipe
- func NewInfinitePipe(priorityFun func(interface{}) bool, limit int) Pipe
- func NewLimitHashInfinitePipe(limit int) Pipe
- func NewLimitInfinitePipe(limit int) Pipe
- func NewLimitPriorityInfinitePipe(priorityFun func(interface{}) bool, limit int) Pipe
- func NewPriorityHashInfinitePipe(priorityFun func(interface{}) bool) Pipe
- func NewPriorityInfinitePipe(priorityFun func(interface{}) bool) Pipe
- type Queue
- func NewDefaultLimitedPriorityHashQueue() Queue
- func NewHashLimitedPriorityHashQueue(hashNeeded bool) Queue
- func NewLimitHashLimitedPriorityHashQueue(limit int, hashNeeded bool) Queue
- func NewLimitLimitedPriorityHashQueue(limit int) Queue
- func NewLimitPriorityLimitedPriorityHashQueue(priorityFun func(interface{}) bool, limit int) Queue
- func NewLimitedPriorityHashQueue(priorityFun func(interface{}) bool, limit int, hashNeeded bool) Queue
- func NewPriorityHashLimitedPriorityHashQueue(priorityFun func(interface{}) bool, hashNeeded bool) Queue
- func NewPriorityLimitedPriorityHashQueue(priorityFun func(interface{}) bool) Queue
- type SimpleHashable
Constants ¶
const Infinity = 0
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 NewLimitInfinitePipe ¶
func NewPriorityInfinitePipe ¶
type Queue ¶
type Queue interface { Length() int Add(elem interface{}) bool Peek() interface{} Get(i int) interface{} Remove() interface{} }
func NewDefaultLimitedPriorityHashQueue ¶
func NewDefaultLimitedPriorityHashQueue() Queue
type SimpleHashable ¶
type SimpleHashable int
func (SimpleHashable) GetHash ¶
func (sh SimpleHashable) GetHash() hashing.HashValue