xlist

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type List

type List interface {
	// 在链表尾部添加一个元素
	// Param:o 添加的对象
	PushBack(o interface{})

	// 在链表首部添加一个元素
	// Param:o 添加的对象
	PushFront(o interface{})

	// 删除元素
	// Param:o 添加的对象
	Remove(o interface{})

	// 获得首元素
	// Return: 首元素(第一个元素),如果没有返回nil
	Front() interface{}

	// 获得尾元素
	// Return: 尾元素(最后一个元素),如果没有返回nil
	Back() interface{}

	// 获得首元素并移除
	// Return: 首元素(第一个元素),如果没有返回nil
	PopFront() interface{}

	// 获得尾元素并移除
	// Return: 尾元素(最后一个元素),如果没有返回nil
	PopBack() interface{}

	// 获得链表长度
	// Return: 链表长度
	Len() int

	// 轮询链表O(N)
	// Param:接受轮询的函数,返回true继续轮询,返回false终止轮询
	Foreach(f func(interface{}) bool)

	// 查询链表中是否存在参数对象
	// Param:查询的对象
	// Return:存在返回true,不存在返回false
	Find(i interface{}) bool
}

type SimpleList

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

func NewSimpleList

func NewSimpleList() *SimpleList

func (*SimpleList) Back

func (l *SimpleList) Back() interface{}

获得尾元素 Return: 尾元素(最后一个元素),如果没有返回nil

func (*SimpleList) Find

func (l *SimpleList) Find(i interface{}) bool

查询链表中是否存在参数对象O(N) Param:查询的对象 Return:存在返回true,不存在返回false

func (*SimpleList) Foreach

func (l *SimpleList) Foreach(f func(interface{}) bool)

轮询链表O(N) Param:接受轮询的函数,返回true继续轮询,返回false终止轮询

func (*SimpleList) Front

func (l *SimpleList) Front() interface{}

获得首元素 Return: 首元素(第一个元素),如果没有返回nil

func (*SimpleList) Len

func (l *SimpleList) Len() int

获得链表长度 Return: 链表长度

func (*SimpleList) PopBack

func (l *SimpleList) PopBack() interface{}

获得尾元素并移除 Return: 尾元素(最后一个元素),如果没有返回nil

func (*SimpleList) PopFront

func (l *SimpleList) PopFront() interface{}

获得首元素并移除 Return: 首元素(第一个元素),如果没有返回nil

func (*SimpleList) PushBack

func (l *SimpleList) PushBack(o interface{})

在链表尾部添加一个元素 Param:o 添加的对象

func (*SimpleList) PushFront

func (l *SimpleList) PushFront(o interface{})

在链表首部添加一个元素 Param:o 添加的对象

func (*SimpleList) Remove

func (l *SimpleList) Remove(o interface{})

删除元素O(N) Param:o 添加的对象

Jump to

Keyboard shortcuts

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