_11_queue_on_array

package
v0.0.0-...-6d07767 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SqQueue

type SqQueue []interface{}

顺序队列实现:数组本身就可以看做是一个顺序队列

func NewSqQueue

func NewSqQueue(capacity int) SqQueue

func (SqQueue) DeQueue

func (this SqQueue) DeQueue() (SqQueue, interface{})

func (SqQueue) EnQueue

func (this SqQueue) EnQueue(element interface{}) SqQueue

type SqQueue2

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

使用结构体实现的队列,这种方式有个缺陷,出队列后只是移动了head指针,数组空间没有被合理利用,可以演进为循环队列

func NewSqQueue2

func NewSqQueue2(n int) *SqQueue2

func (*SqQueue2) DeQueue

func (this *SqQueue2) DeQueue() interface{}

func (*SqQueue2) EnQueue

func (this *SqQueue2) EnQueue(element interface{})

type SqQueueInterface

type SqQueueInterface interface {
	// 进队列
	//  @param interface{}
	EnQueue(interface{}) SqQueue

	// 出队列
	//  @return SqQueue
	//  @return interface{}
	DeQueue() (SqQueue, interface{})
}

Jump to

Keyboard shortcuts

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