common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2018 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package common contains commonly used data structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApproxEqual

func ApproxEqual(a, b, eps float64) bool

func DrawColor

func DrawColor(file *os.File, c *Color)

DrawColor simply calls fmt.Fprintf and writes the RGB components of c to file.

func DrawColorRGB

func DrawColorRGB(file *os.File, r, g, b int)

DrawColorRGB simply calls fmt.Fprintf and writes the RGB components (r, g, b) to file.

Types

type Collection

type Collection interface {
	// Give inserts an element into an arbitrary position of the data type, dependant on
	// implementation.
	Give(e interface{})
	// Take returns and removes an element from the data type. What element and in which position is
	// dependant on implementation.
	Take() interface{}
	// Peek returns an element from the data type. Which of the element is to be peeked at is
	// dependant on implementation.
	Peek() interface{}
	// Get returns the i-th element of the data type.
	Get(i int) interface{}
	// Size returns the size of the data type in number of elements.
	Size() int
	// Empty returns whether the data type is empty or not.
	Empty() bool
	// Shrink shrinks to fit.
	Shrink()
	// Reset empties this collection.
	Reset()
	// Invert inverts a collection (i.e. first becomes last, second becomes second last, etc.).
	Invert() Collection
}

type Color

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

Color (RGB).

var Black *Color

Black color.

var Blue *Color

Blue color.

var Green *Color

Green color.

var Red *Color

Red color.

var White *Color

White color.

func NewColor

func NewColor(r, g, b int) *Color

NewColor creates a new color given components.

func RandColor

func RandColor() *Color

RandColor returns a random color.

func RandColorScale

func RandColorScale(p, max, h, s, minB float64) *Color

RandColorScale returns a scaled color according to the interval [0,max], point and tone given.

func RandTone

func RandTone(h float64) *Color

RandTone returns a random tone for a given hue tone (HSV).

func (*Color) String

func (c *Color) String() string

String returns a color string representation.

type Queue

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

Queue is a queue of interface{}s.

func (*Queue) Dequeue

func (q *Queue) Dequeue() interface{}

Dequeue removes and returns the first element of the queue.

func (*Queue) DequeueBack

func (q *Queue) DequeueBack() interface{}

DequeueBack removes and returns the last element of the queue.

func (*Queue) Empty

func (q *Queue) Empty() bool

Empty returns whether the queue is empty or not.

func (*Queue) Enqueue

func (q *Queue) Enqueue(e interface{})

Enqueue inserts element e at the end of the queue.

func (*Queue) Get

func (q *Queue) Get(i int) interface{}

Get returns the i-th element of the queue.

func (*Queue) Give

func (q *Queue) Give(e interface{})

Give is equivalent to Enqueue.

func (*Queue) Invert

func (q *Queue) Invert() Collection

Invert inverts this Queue.

func (*Queue) Peek

func (q *Queue) Peek() interface{}

Peek returns the first element of the queue.

func (*Queue) Reset

func (q *Queue) Reset()

Reset empties this queue.

func (*Queue) Shrink

func (q *Queue) Shrink()

Shrink shrinks the queue to fit.

func (*Queue) Size

func (q *Queue) Size() int

Size returns the size of the queue.

func (*Queue) Take

func (q *Queue) Take() interface{}

Take is equivalent to Dequeue.

type Stack

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

Stack is a stack of interface{}s.

func (*Stack) Empty

func (s *Stack) Empty() bool

Empty returns whether pointer stack s is empty or not.

func (*Stack) Get

func (s *Stack) Get(i int) interface{}

Get returns the i-th element of the stack. Strongly discouraged, since this is a stack.

func (*Stack) Give

func (s *Stack) Give(e interface{})

Give is equivalent to Push.

func (*Stack) Invert

func (s *Stack) Invert() Collection

Invert inverts this Stack.

func (*Stack) Peek

func (s *Stack) Peek() interface{}

Peek returns the top of the stack.

func (*Stack) Pop

func (s *Stack) Pop() interface{}

Pop removes and returns the last element of pointer stack s.

func (*Stack) Push

func (s *Stack) Push(e interface{})

Push puts element e on top of the pointer stack s.

func (*Stack) Reset

func (s *Stack) Reset()

Reset empties this queue.

func (*Stack) Shrink

func (s *Stack) Shrink()

Shrink shrinks the queue to fit.

func (*Stack) Size

func (s *Stack) Size() int

Size returns the size of pointer stack s.

func (*Stack) Take

func (s *Stack) Take() interface{}

Take is equivalent to Pop.

Jump to

Keyboard shortcuts

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