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 ¶
- Variables
- type Queue
- type Stack
- type Vector
- func (vc *Vector) Array() []interface{}
- func (vec1 *Vector) Difference(vec2 *Vector) *Vector
- func (vc *Vector) Empty()
- func (vc *Vector) Erase(index int)
- func (vc *Vector) GetValueOfIndex(index int) (interface{}, error)
- func (vc *Vector) Insert(data interface{}) int
- func (vc *Vector) InsertInto(index int, data interface{})
- func (vc *Vector) IsEmpty() bool
- func (vc *Vector) Push_back(data interface{}, resizeStep, checkDistance int)
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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.
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 ¶
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.
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 (*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 ¶
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 (*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.