common

package
v0.0.0-...-eb9c356 Latest Latest
Warning

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

Go to latest
Published: May 21, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package common is composed of data structures and other common structures to ease development.

Package common is composed of data structures and other common structures to ease development.

Index

Constants

This section is empty.

Variables

View Source
var LogErr, LogWarn, LogInfo *log.Logger

Functions

This section is empty.

Types

type Queue

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

FIFO queue based on the C++ std::queue class.

func (*Queue) Array

func (stk *Queue) Array() []interface{}

Array walks through the queue and appends each element to an array to be returned.

func (*Queue) Dequeue

func (stk *Queue) Dequeue() (interface{}, error)

Dequeue removes the least recently added data structure: the structure at the front of the queue. After returning the data structure, the queue's head pointer is updated to the data structure immediately following the one just removed.

func (*Queue) IsEmpty

func (stk *Queue) IsEmpty() bool

IsEmpty returns true if there are no data structures in the queue. This will be true if the same number of items queued have been dequeued.

func (*Queue) Peek

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

Peek will return the value at the front of the queue: the next item to be removed. However, Peek will not remove the data structure from the queue. It can be seen again after calling the function.

func (*Queue) Queue

func (stk *Queue) Queue(a interface{})

Queue adds a data structure to the back of the queue

type Stack

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

Stack implements a LIFO stack similar to C++ std::stack

func (*Stack) IsEmpty

func (stk *Stack) IsEmpty() bool

IsEmpty returns true if there are no data structures in the stack. If the same number of data structures have been pushed as poped, then IsEmpty will return true.

func (*Stack) Pop

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

Pop removes and returns the top data structure of the stack.

func (*Stack) Push

func (stk *Stack) Push(val interface{})

Push adds a data structure to the top of the stack.

func (*Stack) Top

func (stk *Stack) Top() interface{}

Top returns the value at the top of the stack without removing it from the stack.

type Vector

type Vector struct {
	Length int
	// contains filtered or unexported fields
}

Vector is a resizeable array. It takes its name from the C++ std::vector class.

func MakeVector

func MakeVector() *Vector

MakeVector returns a pointer to a Vector

func (*Vector) Array

func (vc *Vector) Array() []interface{}

Array returns the underlying array used by the vector

func (*Vector) Difference

func (vec1 *Vector) Difference(vec2 *Vector) *Vector

Difference will return a vector that is composed of the data structures that were unique in one of the two input vectors.

func (*Vector) Empty

func (vc *Vector) Empty()

Empty will delete all data in the vector and essentially create a new vector.

func (*Vector) Erase

func (vc *Vector) Erase(index int)

Erase will delete the data from an array position in the vector.

func (*Vector) GetValueOfIndex

func (vc *Vector) GetValueOfIndex(index int) (interface{}, error)

GetValueOfIndex returns the value at the index requested.

func (*Vector) Insert

func (vc *Vector) Insert(data interface{}) int

Insert will attempt to insert a value into the vector using an empty slot. If no empty space is found, Insert resorts to Push_back to append the data structure to the end of the vector.

func (*Vector) InsertInto

func (vc *Vector) InsertInto(index int, data interface{})

func (*Vector) IsEmpty

func (vc *Vector) IsEmpty() bool

func (*Vector) Push_back

func (vc *Vector) Push_back(data interface{}, resizeStep, checkDistance int)

Push_back will append a data structure to the end of the vector. If the length of the vector is less than the space required for the new data structure, then the vector is extended and the data is copied into the new, bigger vector. Then the new data structure is appended to the end.

Jump to

Keyboard shortcuts

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