base_algo

package
v0.0.0-...-0216257 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 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 ArrayQueue

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

* 顺序队列:用数组实现的队列 同样是个循环队列

func (*ArrayQueue) Dequeue

func (this *ArrayQueue) Dequeue() interface{}

func (*ArrayQueue) Enqueue

func (this *ArrayQueue) Enqueue(data interface{}) bool

type BlockArrayQueue

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

* 阻塞队列 数组实现方式 利用双向cahnnel TODO 使用CAS保证出队和入队的线程安全性,即是实现一种线程安全队列

func (*BlockArrayQueue) Dequeue

func (this *BlockArrayQueue) Dequeue() interface{}

* 先获取lockers,然后才能获取items

func (*BlockArrayQueue) Enqueue

func (this *BlockArrayQueue) Enqueue(data interface{}) bool

* 先写入items,然后写入lockers

type LinkedList

type LinkedList struct {
	Head *Node
	Tail *Node
}

func (*LinkedList) Exist

func (this *LinkedList) Exist(value interface{})

func (*LinkedList) Insert

func (this *LinkedList) Insert(node *Node)

func (*LinkedList) InsertHead

func (this *LinkedList) InsertHead(node *Node)

func (*LinkedList) PrintList

func (this *LinkedList) PrintList()

func (*LinkedList) Remove

func (this *LinkedList) Remove(node *Node)

func (*LinkedList) Reverse

func (this *LinkedList) Reverse() *LinkedList

* 单链表反转

type LinkedQueue

type LinkedQueue struct {
}

* 链表队列

type Node

type Node struct {
	Val      interface{}
	Previous *Node
	Next     *Node
}

func ReverseList

func ReverseList(head *Node) *Node

反转单链表,会破坏原链表

func (*Node) PrintNode

func (this *Node) PrintNode()

type NodeValue

type NodeValue struct {
	Value int
}

type Queue

type Queue interface {
	Enqueue(data interface{}) bool
	Dequeue() interface{}
}

* 队列:先进先出 最基本的操作:

Enqueue-入队
Dequeue-出队

Jump to

Keyboard shortcuts

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