binaryheap

package
v0.0.0-...-e595a67 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryHeap

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

BinaryHeap is a binary search tree with a prioritet

func NewBinaryHeap

func NewBinaryHeap(values ...Enterprice) *BinaryHeap

NewBinaryHeap is a constructor, which returns pointer on a new heap object

func (*BinaryHeap) Count

func (heap *BinaryHeap) Count() int

Count is a method which returns count of items in BinaryHeap

func (*BinaryHeap) GetTop25

func (heap *BinaryHeap) GetTop25() []Enterprice

GetTop25 returns top 25 the most profit companies

func (*BinaryHeap) Height

func (heap *BinaryHeap) Height() int

Height is a method, which retunrs count of levels in heap

func (*BinaryHeap) Pop

func (heap *BinaryHeap) Pop() (*Enterprice, bool)

Pop is a method, which returns the first item of heap

func (*BinaryHeap) Print

func (heap *BinaryHeap) Print()

Print is a method, which allows to print out a heap

func (*BinaryHeap) Push

func (heap *BinaryHeap) Push(value Enterprice)

Push is a method, which allows to add a new item to the heap

func (*BinaryHeap) Root

func (heap *BinaryHeap) Root() *Binder

Root is a method, which retunrs first item of data array

func (*BinaryHeap) Validate

func (heap *BinaryHeap) Validate() bool

Validate is a method, which validate a heap

type Binder

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

Binder is a struct which works like a node in BinaryHeap for printing a heap

func (*Binder) Depth

func (binder *Binder) Depth() int

Depth is a method, witch returns in which level item located

func (*Binder) Height

func (binder *Binder) Height() int

Height is a method, which returns how many levels in the heap

func (*Binder) LeftChild

func (binder *Binder) LeftChild() *Binder

LeftChild is a method, which return a pointer on the left child

func (*Binder) Parent

func (binder *Binder) Parent() *Binder

Parent is a method, which returns a parrent of node

func (*Binder) RightChild

func (binder *Binder) RightChild() *Binder

RightChild is a method, which returns a poiner on the right child

func (*Binder) Value

func (binder *Binder) Value() *Enterprice

Value is a method, which returns a value of node

type Enterprice

type Enterprice struct {
	Name    string
	Address string
	Month   time.Month
	Year    int
	Profit  int
}

Enterprice is a structure, which allows us to store informatqion about some company

func NewEnterprice

func NewEnterprice(name, address string, month time.Month, year, profit int) Enterprice

NewEnterprice is a constructor, which returns a pointer of new enterprice structure

Jump to

Keyboard shortcuts

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