Documentation ¶
Overview ¶
Package structs contains queue, stack and tree structs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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) 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 (*Tree) RightChild ¶
RightChild returns the right tree child node.