ring

package module
v0.0.0-...-9a7a055 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: MIT Imports: 4 Imported by: 0

README

ring

A ring data-structure in go

Documentation

Index

Constants

View Source
const (
	// FORWARD seek
	FORWARD = iota
	// BACKWARD seek
	BACKWARD
)

Variables

View Source
var (
	// STDOUT mapping of os lib
	STDOUT = os.Stdout
)

Functions

This section is empty.

Types

type Index

type Index uint

Index of a node inside a ring

type Node

type Node struct {
	NodeName  []byte      `json:"name"`
	NodeValue interface{} `json:"value"`
	// contains filtered or unexported fields
}

Node in a ring

func (*Node) Fit

func (node *Node) Fit(prior *Node, next *Node) *Node

Fit a node between two nodes

func (*Node) Init

func (node *Node) Init(name []byte) *Node

Init names a node

func (*Node) JSON

func (node *Node) JSON() ([]byte, error)

JSON returns json of a node

func (*Node) Name

func (node *Node) Name() []byte

Name returns the nodes name

func (*Node) Next

func (node *Node) Next() *Node

Next node of ring

func (*Node) Print

func (node *Node) Print() *Node

Print the nodes information to the screen

func (*Node) Prior

func (node *Node) Prior() *Node

Prior node of ring

func (*Node) Ring

func (node *Node) Ring() *Ring

Ring returns ring of node

func (*Node) Set

func (node *Node) Set(value interface{}) *Node

Set a value of a node

func (*Node) Value

func (node *Node) Value() interface{}

Value returns a nodes value

type Ring

type Ring Node

Ring of nodes

func (*Ring) Array

func (ring *Ring) Array() []*Node

Array returns array of nodes

func (*Ring) Find

func (ring *Ring) Find(finder func(*Node) bool) (Index, error)

Find a node based on a injection

func (*Ring) Init

func (ring *Ring) Init(nodes [][]byte) *Ring

Init returns a ring of named nodes

func (*Ring) JSON

func (ring *Ring) JSON() ([]byte, error)

JSON returns json of ring

func (*Ring) Node

func (ring *Ring) Node() *Node

Node from a Ring

func (*Ring) Pop

func (ring *Ring) Pop() *Node

Pop a node from the ring

func (*Ring) Push

func (ring *Ring) Push(nx *Node) *Ring

Push a node behind another

func (*Ring) Seek

func (ring *Ring) Seek(index Index) (*Node, error)

Seek the node by index

func (*Ring) Skip

func (ring *Ring) Skip(n Index) *Ring

Skip to the node

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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