queue

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyQueue   = errors.New("queue is empty")
	ErrItemNotFound = errors.New("item never pushed to queue")
	ErrOutOfRange   = errors.New("n is greater than length of queue")
)

Functions

This section is empty.

Types

type UniqueQueue

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

UniqueQueue holds unique values in its queue

func NewQueue

func NewQueue() *UniqueQueue

NewQueue returns a pointer to new UniqueQueue

Care: Map is case-sensitive. Use strings.ToLower on key to make case-insensitive.

func (*UniqueQueue) Clear

func (q *UniqueQueue) Clear()

Clear removes all items from the queue but not from its map

func (*UniqueQueue) FirstEncounter

func (q *UniqueQueue) FirstEncounter(item string) bool

FirstEncounter returns true if the item was seen for the first time by the queue in its lifetime

func (*UniqueQueue) GetMapValue

func (q *UniqueQueue) GetMapValue(key string) (bool, error)

GetMapValue returns value of key inside the map used by UniqueQueue.

It throws ErrItemNotFound when the item couldn't be found in the map, this means that the item was never pushed to the queue.

Thread safe.

func (*UniqueQueue) Insert added in v0.8.5

func (q *UniqueQueue) Insert(item string) (success bool)

Insert appends item to the queue after checking that item was never seen before by the queue. Returns true if item was added to the queue.

Care: Map is case-sensitive. Use strings.ToLower to make case-insensitive.

NOP when item was seen earlier in queue's lifetime. Default item value is 'false'.

Thread safe.

func (*UniqueQueue) InsertForce added in v0.8.5

func (q *UniqueQueue) InsertForce(item string)

InsertForce appends item to the queue WITHOUT checking that the item was seen before. Useful when item was not processed successfully and/or needs to be reprocessed. Or while bulk loading from unique set.

Care: Map is case-sensitive. Use strings.ToLower to make case-insensitive.

Default item value is 'false'.

Thread safe.

func (*UniqueQueue) IsEmpty

func (q *UniqueQueue) IsEmpty() bool

IsEmpty tells if queue is empty or not

func (*UniqueQueue) Remove added in v0.8.5

func (q *UniqueQueue) Remove() (string, error)

Remove pops first item from the queue. Returns ErrEmptyQueue when empty.

Thread safe.

func (*UniqueQueue) SetMapValue

func (q *UniqueQueue) SetMapValue(key string, value bool)

SetMapValue set value of key inside the map used by UniqueQueue.

Thread safe.

func (*UniqueQueue) Size

func (q *UniqueQueue) Size() int

Size returns the size of queue

func (*UniqueQueue) View

func (q *UniqueQueue) View(n int) (string, error)

View the first n items of the queue

Jump to

Keyboard shortcuts

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