queue

package module
v0.0.0-...-c4cf18b Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: MIT Imports: 0 Imported by: 0

README

golang-simple-queue

This is a super simple linked list queue.

Methods

New() - This method creates a new instance of the queue.

queue := queue.New()

Append() - This method appends a new item to the queue as a string.

item := `{id:1, message: "Thing to work on"}`
queue := queue.Append(item)

Pull() - This method pulls an item from the queue and removes its reference.

data := queue.Pull()

Empty() - Checks to see if there are any messages left on the queue.

Simple example to show usage

package main

import (
	"github.com/safurr/golang-simple-queue"
	"fmt"
)

func main() {
	queue := queue.New()
	item := `{id:1, message: "Thing to work on"}`
	queue.Append(item)
	for queue.Empty() == false {
		data := queue.Pull()
		fmt.Printf("Data: %s\n", data)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

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

type Queue

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

func New

func New() *Queue

func (*Queue) Append

func (q *Queue) Append(input string)

func (*Queue) Empty

func (q *Queue) Empty() bool

func (*Queue) Pull

func (q *Queue) Pull() string

Jump to

Keyboard shortcuts

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