dlist

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element = list.Element

Element 链表中的节点类型

type List

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

List 是一个包含并发安全开关的双向链表,开关在对象创建的时候确认,并且不能更改。

func New

func New(safe ...bool) *List

New 创建

Example
package main

import (
	"fmt"
	"github.com/osgochina/donkeygo/container/dlist"
)

func main() {
	n := 10
	l := dlist.New()
	for i := 0; i < n; i++ {
		l.PushBack(i)
	}
	fmt.Println(l.Len())
	fmt.Println(l.FrontAll())
	fmt.Println(l.BackAll())
	for i := 0; i < n; i++ {
		fmt.Print(l.PopFront())
	}
	l.Clear()
	fmt.Println()
	fmt.Println(l.Len())

}
Output:

10
[0 1 2 3 4 5 6 7 8 9]
[9 8 7 6 5 4 3 2 1 0]
0123456789
0

func NewFrom

func NewFrom(array []interface{}, safe ...bool) *List

NewFrom 创建一个链表,并把切片中的对象填充进该链表

func (*List) Back

func (that *List) Back() (e *Element)

Back 获取链表的尾部节点

func (*List) BackAll

func (that *List) BackAll() (values []interface{})

BackAll 查看链表从尾开始的所有值

func (*List) BackValue

func (that *List) BackValue() (value interface{})

BackValue 查看链表尾部的值

func (*List) Clear

func (that *List) Clear()

Clear 清空链表

func (*List) Front

func (that *List) Front() (e *Element)

Front 获取链表的头部节点

func (*List) FrontAll

func (that *List) FrontAll() (values []interface{})

FrontAll 查看链表从头开始的所有值

func (*List) FrontValue

func (that *List) FrontValue() (value interface{})

FrontValue 查看链表头部的值

func (*List) InsertAfter

func (that *List) InsertAfter(p *Element, v interface{}) (e *Element)

InsertAfter 插入值v到节点p的后面,并返回该节点

func (*List) InsertBefore

func (that *List) InsertBefore(p *Element, v interface{}) (e *Element)

InsertBefore 插入值v到节点p的前面,并返回该节点

func (*List) Iterator

func (that *List) Iterator(f func(e *Element) bool)

Iterator 迭代

func (*List) IteratorAsc

func (that *List) IteratorAsc(f func(e *Element) bool)

IteratorAsc 从头开始迭代

func (*List) IteratorDesc

func (that *List) IteratorDesc(f func(e *Element) bool)

IteratorDesc 从尾部开始迭代

func (*List) Join

func (that *List) Join(glue string) string

Join 把链表中的值,按glue分隔符链接起来

func (*List) Len

func (that *List) Len() (length int)

Len 获取链表的长度

func (*List) LockFunc

func (that *List) LockFunc(f func(list *list.List))

LockFunc 加读写锁执行函数

func (*List) MarshalJSON

func (that *List) MarshalJSON() ([]byte, error)

MarshalJSON 把链表转成json串

func (*List) MoveAfter

func (that *List) MoveAfter(e, p *Element)

MoveAfter 把e节点移动到p节点的后面

func (*List) MoveBefore

func (that *List) MoveBefore(e, p *Element)

MoveBefore 把e节点从链表中移动到p节点的前面

func (*List) MoveToBack

func (that *List) MoveToBack(e *Element)

MoveToBack 把节点e移动到链表的尾部

func (*List) MoveToFront

func (that *List) MoveToFront(e *Element)

MoveToFront 把节点e移动到链表的头部

func (*List) PopBack

func (that *List) PopBack() interface{}

PopBack 获取链表的尾节点的值,并且移除该节点

func (*List) PopBackAll

func (that *List) PopBackAll() []interface{}

PopBackAll 从链表尾部开始取,取出全部的值

func (*List) PopBacks

func (that *List) PopBacks(max int) (values []interface{})

PopBacks 取出链表尾部最多max个节点的值

func (*List) PopFront

func (that *List) PopFront() interface{}

PopFront 获取链表的头节点的值,并且移除该节点

func (*List) PopFrontAll

func (that *List) PopFrontAll() []interface{}

PopFrontAll 从链表头部开始取,取出全部的值

func (*List) PopFronts

func (that *List) PopFronts(max int) (values []interface{})

PopFronts 取出链表头部最多max个节点的值

func (*List) PushBack

func (that *List) PushBack(v interface{}) *Element

PushBack 往链表的尾部插入一个值为v的节点,并返回该节点

func (*List) PushBackList

func (that *List) PushBackList(other *List)

PushBackList 把链表other链接到链表的尾部

func (*List) PushBacks

func (that *List) PushBacks(values []interface{})

PushBacks 往链表的尾部插入多个值

func (*List) PushFront

func (that *List) PushFront(v interface{}) *Element

PushFront 往链表的头部插入一个值为v的节点,并返回该节点

func (*List) PushFrontList

func (that *List) PushFrontList(other *List)

PushFrontList 把链表other链接到链表的头部

func (*List) PushFronts

func (that *List) PushFronts(values []interface{})

PushFronts 往链表的头部插入多个值

func (*List) RLockFunc

func (that *List) RLockFunc(f func(list *list.List))

RLockFunc 加读锁执行函数

func (*List) Remove

func (that *List) Remove(e *Element) (value interface{})

Remove 移除节点e,并返回该节点的值

func (*List) RemoveAll

func (that *List) RemoveAll()

RemoveAll 移除所有节点

func (*List) Removes

func (that *List) Removes(es []*Element)

Removes 移除指定的一批节点

func (*List) Size

func (that *List) Size() int

Size 获取链表的长度

func (*List) String

func (that *List) String() string

把链表转成字符串

func (*List) UnmarshalJSON

func (that *List) UnmarshalJSON(b []byte) error

UnmarshalJSON 把json串反序列化成链表

func (*List) UnmarshalValue

func (that *List) UnmarshalValue(value interface{}) (err error)

UnmarshalValue 解码内容

Jump to

Keyboard shortcuts

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