Documentation ¶
Overview ¶
Package common contains commonly used data structures.
Index ¶
- func ApproxEqual(a, b, eps float64) bool
- func DrawColor(file *os.File, c *Color)
- func DrawColorRGB(file *os.File, r, g, b int)
- type Collection
- type Color
- type Queue
- func (q *Queue) Dequeue() interface{}
- func (q *Queue) DequeueBack() interface{}
- func (q *Queue) Empty() bool
- func (q *Queue) Enqueue(e interface{})
- func (q *Queue) Get(i int) interface{}
- func (q *Queue) Give(e interface{})
- func (q *Queue) Invert() Collection
- func (q *Queue) Peek() interface{}
- func (q *Queue) Reset()
- func (q *Queue) Shrink()
- func (q *Queue) Size() int
- func (q *Queue) Take() interface{}
- type Stack
- func (s *Stack) Empty() bool
- func (s *Stack) Get(i int) interface{}
- func (s *Stack) Give(e interface{})
- func (s *Stack) Invert() Collection
- func (s *Stack) Peek() interface{}
- func (s *Stack) Pop() interface{}
- func (s *Stack) Push(e interface{})
- func (s *Stack) Reset()
- func (s *Stack) Shrink()
- func (s *Stack) Size() int
- func (s *Stack) Take() interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApproxEqual ¶
func DrawColorRGB ¶
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 RandColorScale ¶
RandColorScale returns a scaled color according to the interval [0,max], point and tone given.
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) Enqueue ¶
func (q *Queue) Enqueue(e interface{})
Enqueue inserts element e at the end of the queue.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack is a stack of interface{}s.
func (*Stack) Get ¶
Get returns the i-th element of the stack. Strongly discouraged, since this is a stack.
func (*Stack) Pop ¶
func (s *Stack) Pop() interface{}
Pop removes and returns the last element of pointer stack s.