queue

package
v0.0.0-...-bc502ad Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

这是一个先进先出队列的包

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

type Queue []int

表示队列,队列本身是一个int切片

func (*Queue) IsEmpty

func (q *Queue) IsEmpty() bool

判断队列是否为空的方法。若队列为空,则返回true;否则返回false

func (*Queue) Pop

func (q *Queue) Pop() int

队列的出队方法,将队列的首部第一个元素弹出,方法将返回弹出的值

Example
q := Queue{1, 2, 3}
q.Push(4) // 将4压入队列
fmt.Println("origin queue is :", q)
fmt.Printf("head first of the queue:%d, has been popped\n", q.Pop())
fmt.Println("the queue after pop action is :", q)
Output:

origin queue is : [1 2 3 4]
head first of the queue:1, has been popped
the queue after pop action is : [2 3 4]

func (*Queue) Push

func (q *Queue) Push(v int)

队列的入队方法,将传入的int压入队列

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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