structs

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package structs contains queue, stack and tree structs.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPopEmptyStack return error if stack is empty.
	ErrPopEmptyStack = errors.New("stack is empty")
	// ErrPopEmptyQueue return error if queue is empty.
	ErrPopEmptyQueue = errors.New("queue is empty")
)

Functions

This section is empty.

Types

type StringQueue

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

StringQueue contains queue of strings.

func (*StringQueue) Clear

func (q *StringQueue) Clear()

Clear clears the queue.

func (*StringQueue) IsEmpty

func (q *StringQueue) IsEmpty() bool

IsEmpty return true if the queue is empty and false otherwise.

func (*StringQueue) IsNotEmpty

func (q *StringQueue) IsNotEmpty() bool

IsNotEmpty return true if the queue is not empty and false otherwise.

func (*StringQueue) Pop

func (q *StringQueue) Pop() (string, error)

Pop shifts the string element off the beginning of the queue or return ErrPopEmptyQueue error if the queue is empty.

func (*StringQueue) PopAllAndClear

func (q *StringQueue) PopAllAndClear() []string

PopAllAndClear returns all queue elements and clears the queue.

func (*StringQueue) Push

func (q *StringQueue) Push(value string)

Push adds string value to the queue.

type StringStack

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

StringStack contains stack of strings.

func (*StringStack) IsEmpty

func (s *StringStack) IsEmpty() bool

IsEmpty return true if the stack is empty and false otherwise.

func (*StringStack) IsNotEmpty

func (s *StringStack) IsNotEmpty() bool

IsNotEmpty return true if the stack is not empty and false otherwise.

func (*StringStack) IsTopEqual

func (s *StringStack) IsTopEqual(val string) bool

IsTopEqual return true if the last element of the stack is equal to val and false otherwise.

func (*StringStack) Pop

func (s *StringStack) Pop() (string, error)

Pop pops the string element off the end of the stack and ErrPopEmptyStack error if the stack is empty.

func (*StringStack) Push

func (s *StringStack) Push(value string)

Push adds string value to the stack.

func (*StringStack) Top

func (s *StringStack) Top() (string, error)

Top returns the string element off the end of the stack and a ErrPopEmptyStack error if the stack is empty.

type Tree

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

Tree contains a tree node.

func NewTree

func NewTree(value interface{}, left, right *Tree) *Tree

NewTree return new tree node.

func (*Tree) GetValue

func (t *Tree) GetValue() interface{}

GetValue returns the node value.

func (*Tree) LeftChild

func (t *Tree) LeftChild() *Tree

LeftChild returns the left tree child node.

func (*Tree) RightChild

func (t *Tree) RightChild() *Tree

RightChild returns the right tree child node.

type TreeStack

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

TreeStack contains stack of tree pointers.

func (*TreeStack) Pop

func (s *TreeStack) Pop() (*Tree, error)

Pop pops the tree element off the end of the stack and ErrPopEmptyStack error if the stack is empty.

func (*TreeStack) Push

func (s *TreeStack) Push(value *Tree)

Push adds tree pointer value to the stack.

Jump to

Keyboard shortcuts

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