queue

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: BSL-1.0 Imports: 1 Imported by: 0

README

queue

GoDoc Go Report Card

About

This package provides generic queues. It is published on https://github.com/vbsw/queue.

Copyright 2021 Vitali Baumtrok (vbsw@mailbox.org).

queue is distributed under the Boost Software License, version 1.0. (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)

queue is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Boost Software License for more details.

Example

Code:

package main

import (
	"fmt"
	"github.com/vbsw/queue"
)

func main() {
	simpleQueue := queue.New(2)
	simpleQueue.Put("hi")
	simpleQueue.Put(10)
	fmt.Println(simpleQueue.First(), simpleQueue.First(), simpleQueue.First())
}

Output:

$ hi 10 <nil>

References

Documentation

Overview

Package queue provides generic queues.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

type Queue interface {
	Put(interface{})
	PutAll(...interface{})
	First() interface{}
	All() []interface{}
	Size() int
}

Queue is a "First In, First Out" buffer.

func New

func New(capacity int) Queue

New returns a new queue. If capacity is negative, capacity is set to zero. If capacity is zero, queue is initialized with capacity of 8 at first write.

func NewSynchronized

func NewSynchronized(capacity int) Queue

NewSynchronized returns a new thread safe queue. If capacity is negative, capacity is set to zero. If capacity is zero, queue is initialized with capacity of 8 at first write.

Jump to

Keyboard shortcuts

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