containerg

package
v0.0.0-...-cd66ef8 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IntHeap

type IntHeap []int

An IntHeap is a min-heap of ints.

func (IntHeap) Len

func (h IntHeap) Len() int

func (IntHeap) Less

func (h IntHeap) Less(i, j int) bool

func (*IntHeap) Pop

func (h *IntHeap) Pop() interface{}

func (*IntHeap) Push

func (h *IntHeap) Push(x interface{})

func (IntHeap) Swap

func (h IntHeap) Swap(i, j int)

type Item

type Item struct {
	Value    string // The Value of the item; arbitrary.
	Priority int    // The priority of the item in the queue.
	// The Index is needed by update and is maintained by the heap.Interface methods.
	Index int // The Index of the item in the heap.
}

An Item is something we manage in a priority queue.

type PriorityQueue

type PriorityQueue []*Item

A PriorityQueue implements heap.Interface and holds Items.

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

func (*PriorityQueue) Update

func (pq *PriorityQueue) Update(item *Item, value string, priority int)

update modifies the priority and Value of an Item in the queue.

type RectHeap

type RectHeap []Rectangle

定义一个堆结构体

func (RectHeap) Len

func (rech RectHeap) Len() int

实现heap.Interface接口

func (RectHeap) Less

func (rech RectHeap) Less(i, j int) bool

func (*RectHeap) Pop

func (rech *RectHeap) Pop() (x interface{})

func (*RectHeap) Push

func (rech *RectHeap) Push(h interface{})

实现heap.Interface接口定义的额外方法

func (RectHeap) Swap

func (rech RectHeap) Swap(i, j int)

实现sort.Iterface

type Rectangle

type Rectangle struct {
	Width  int
	Height int
}

定义一个正方形的结构体

func (*Rectangle) Area

func (rec *Rectangle) Area() int

Jump to

Keyboard shortcuts

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