Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrIndexOutOfRange = errors.New("index out of range") ErrQueueIsEmpty = errors.New("empty queue") )
These variables defines typed errors.
Functions ¶
This section is empty.
Types ¶
type Must ¶ added in v0.2.0
type Must struct {
Queue Queue
}
Must wraps a Queue with methods that panic instead of returning error.
Example ¶
q := blobqueue.Must{new(memory.Queue)} fmt.Println(q.Len()) q.Unshift([]byte("AA")) q.Push([]byte("BB")) fmt.Printf("%s\n", q.List()) fmt.Println(q.Len()) fmt.Printf("%s %s\n", q.Pop(), q.Shift()) fmt.Println(q.Len())
Output: 0 [AA BB] 2 BB AA 0
func (Must) Empty ¶ added in v0.2.0
func (q Must) Empty()
Empty transforms errors from Queue.Empty into panic.
type Queue ¶
type Queue interface { // List returns all the items of the queue as [][]byte. List() ([][]byte, error) // Push appends the queue with a new elem (val). Push(val []byte) error // Unshift add a new elem at the beggining of the queue. Unshift(val []byte) error // Pop deletes the last element of the queue, it returns this precise element. // If the queue is empty it returns error ErrQueueIsEmpty. Pop() ([]byte, error) // Shift deletes the first element of the queue, it returns this precise element. // If the queue is empty it returns error ErrQueueIsEmpty. Shift() ([]byte, error) // Len returns the length of the queue. Len() (int, error) // Empty clears the queue. Empty() error }
Queue is an interface providing operations to handle queues. All methods may return an error as its implementation may have runtime failures.
Click to show internal directories.
Click to hide internal directories.