nqueen

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitArray0

func InitArray0(array [][]string, x, y int) error

InitArray0 二维数组 元素默认'0'

func IsLegalLoc

func IsLegalLoc(ql *QueenList, loc *Location) (bool, error)

IsLegalLoc 判断是否在同一行或同一列、是否在同斜线上

func NQueen

func NQueen(ql *QueenList, startX, startY int, Size int) error

NQueen N皇后问题

func PrintArray2

func PrintArray2(array [][]string, x, y int)

PrintArray2 输出二维数组,步骤,先遍历最外层数组,再遍历一唯数组

func PrintQueenList

func PrintQueenList(ql *QueenList, Size int)

PrintQueenList 打印N皇后

Types

type Location

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

func NewLocation

func NewLocation(x, y int) *Location

func (*Location) String

func (l *Location) String() string

type QueenList

type QueenList struct {
	QList *list.LinkedList
	RW    sync.RWMutex
}

QueenList thread safe

func NewQueenList

func NewQueenList() *QueenList

func (*QueenList) AddFirst

func (ql *QueenList) AddFirst(loc *Location)

func (*QueenList) GetList

func (ql *QueenList) GetList() *list.LinkedList

func (*QueenList) RemoveFirst

func (ql *QueenList) RemoveFirst()

Jump to

Keyboard shortcuts

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