list

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: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValid

func IsValid(s string, brackets map[rune]rune) bool

判断某些符号是否对称

func NewArrayStack

func NewArrayStack(capacity int) *arrayStack

Types

type ArrayList

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

func NewArrayList

func NewArrayList(capacity int) *ArrayList

构造函数,传入数组的容量capacity构造Array

func (*ArrayList) Add

func (arrayList *ArrayList) Add(index int, e interface{}) error

在第 index 个位置插入一个新元素 e

func (*ArrayList) AddFirst

func (arrayList *ArrayList) AddFirst(e interface{}) error

向所有元素前添加一个新元素

func (*ArrayList) AddLast

func (arrayList *ArrayList) AddLast(e interface{}) error

向所有元素后添加一个新元素

func (*ArrayList) Capacity

func (arrayList *ArrayList) Capacity() int

获取数组的容量

func (*ArrayList) Contains

func (arrayList *ArrayList) Contains(e interface{}) bool

查找数组中是否有元素 e

func (*ArrayList) Find

func (arrayList *ArrayList) Find(e interface{}) int

查找数组中元素 e 所在的索引,不存在则返回 -1

func (*ArrayList) FindAll

func (arrayList *ArrayList) FindAll(e interface{}) (indexes []int)

查找数组中元素 e 所有的索引组成的切片,不存在则返回 -1

func (*ArrayList) Get

func (arrayList *ArrayList) Get(index int) interface{}

获取 index 索引位置的元素

func (*ArrayList) IsEmpty

func (arrayList *ArrayList) IsEmpty() bool

返回数组是否为空

func (*ArrayList) Remove

func (arrayList *ArrayList) Remove(index int) interface{}

从数组中删除 index 位置的元素,返回删除的元素

func (*ArrayList) RemoveAllElement

func (arrayList *ArrayList) RemoveAllElement(e interface{}) bool

从数组中删除所有元素 e

func (*ArrayList) RemoveElement

func (arrayList *ArrayList) RemoveElement(e interface{}) bool

从数组中删除一个元素 e

func (*ArrayList) RemoveFirst

func (arrayList *ArrayList) RemoveFirst() interface{}

从数组中删除第一个元素,返回删除的元素

func (*ArrayList) RemoveLast

func (arrayList *ArrayList) RemoveLast() interface{}

从数组中删除最后一个元素,返回删除的元素

func (*ArrayList) Set

func (arrayList *ArrayList) Set(index int, e interface{})

修改 index 索引位置的元素

func (*ArrayList) Size

func (arrayList *ArrayList) Size() int

获得数组中的元素个数

func (*ArrayList) String

func (arrayList *ArrayList) String() string

重写 ArrayList 的 string 方法

func (*ArrayList) Swap

func (arrayList *ArrayList) Swap(i int, j int) error

type IStack

type IStack interface {
	Size() int
	IsEmpty() bool
	Push(interface{})
	Pop() interface{}
	Peek() interface{}
}

type LinkedList

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

func NewLinkedList

func NewLinkedList() *LinkedList

func (*LinkedList) Add

func (linkedList *LinkedList) Add(index int, e interface{}) error

在链表的index(0-based)位置添加新的元素e

func (*LinkedList) AddFirst

func (linkedList *LinkedList) AddFirst(e interface{})

在链表头添加新的元素e

func (*LinkedList) AddLast

func (linkedList *LinkedList) AddLast(e interface{}) error

在链表末尾添加新的元素e

func (*LinkedList) Contains

func (linkedList *LinkedList) Contains(e interface{}) bool

查找链表是否存在元素e

func (*LinkedList) Get

func (linkedList *LinkedList) Get(index int) (interface{}, error)

获得链表的第index(0-based)个位置的元素

func (*LinkedList) GetFirst

func (linkedList *LinkedList) GetFirst() (interface{}, error)

获得链表的第一个元素

func (*LinkedList) GetLast

func (linkedList *LinkedList) GetLast() (interface{}, error)

获得链表的最后一个元素

func (*LinkedList) Head

func (linkedList *LinkedList) Head() *Node

func (*LinkedList) IsEmpty

func (linkedList *LinkedList) IsEmpty() bool

返回链表是否为空

func (*LinkedList) Remove

func (linkedList *LinkedList) Remove(index int) (interface{}, error)

从链表中删除index(0-based)位置的元素,返回删除的元素

func (*LinkedList) RemoveElement

func (linkedList *LinkedList) RemoveElement(e interface{})

从链表中删除元素e

func (*LinkedList) RemoveFirst

func (linkedList *LinkedList) RemoveFirst() interface{}

func (*LinkedList) Set

func (linkedList *LinkedList) Set(index int, e interface{}) error

修改链表的第index(0-based)个位置的元素为e

func (*LinkedList) Size

func (linkedList *LinkedList) Size() int

获取链表中的元素个数

func (*LinkedList) String

func (linkedList *LinkedList) String() string

type LoopLinkedList

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

func NewLoopLinkedList

func NewLoopLinkedList() *LoopLinkedList

func (*LoopLinkedList) Add

func (l *LoopLinkedList) Add(index int, e interface{})

func (*LoopLinkedList) AddFirst

func (l *LoopLinkedList) AddFirst(e interface{})

func (*LoopLinkedList) AddLast

func (l *LoopLinkedList) AddLast(e interface{})

func (*LoopLinkedList) Contains

func (l *LoopLinkedList) Contains(e interface{}) bool

func (*LoopLinkedList) Get

func (l *LoopLinkedList) Get(index int) interface{}

func (*LoopLinkedList) GetFirst

func (l *LoopLinkedList) GetFirst() interface{}

func (*LoopLinkedList) GetLast

func (l *LoopLinkedList) GetLast() interface{}

func (*LoopLinkedList) IsEmpty

func (l *LoopLinkedList) IsEmpty() bool

func (*LoopLinkedList) Remove

func (l *LoopLinkedList) Remove(index int) interface{}

func (*LoopLinkedList) RemoveFirst

func (l *LoopLinkedList) RemoveFirst() interface{}

func (*LoopLinkedList) RemoveLast

func (l *LoopLinkedList) RemoveLast() interface{}

func (*LoopLinkedList) Set

func (l *LoopLinkedList) Set(index int, e interface{})

func (*LoopLinkedList) Size

func (l *LoopLinkedList) Size() int

func (*LoopLinkedList) String

func (l *LoopLinkedList) String() string

type LoopNode

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

type Node

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

func (*Node) Next

func (n *Node) Next() *Node

func (*Node) String

func (n *Node) String() string

func (*Node) Value

func (n *Node) Value() interface{}

type TwoWayLinkedList

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

func NewTwoWayLinkedList

func NewTwoWayLinkedList() *TwoWayLinkedList

func (*TwoWayLinkedList) Add

func (l *TwoWayLinkedList) Add(index int, e interface{})

func (*TwoWayLinkedList) AddFirst

func (l *TwoWayLinkedList) AddFirst(e interface{})

func (*TwoWayLinkedList) AddLast

func (l *TwoWayLinkedList) AddLast(e interface{})

func (*TwoWayLinkedList) Contains

func (l *TwoWayLinkedList) Contains(e interface{}) bool

func (*TwoWayLinkedList) Get

func (l *TwoWayLinkedList) Get(index int) interface{}

func (*TwoWayLinkedList) GetFirst

func (l *TwoWayLinkedList) GetFirst() interface{}

func (*TwoWayLinkedList) GetLast

func (l *TwoWayLinkedList) GetLast() interface{}

func (*TwoWayLinkedList) IsEmpty

func (l *TwoWayLinkedList) IsEmpty() bool

func (*TwoWayLinkedList) Remove

func (l *TwoWayLinkedList) Remove(index int) interface{}

func (*TwoWayLinkedList) RemoveFirst

func (l *TwoWayLinkedList) RemoveFirst() interface{}

func (*TwoWayLinkedList) RemoveLast

func (l *TwoWayLinkedList) RemoveLast() interface{}

func (*TwoWayLinkedList) Set

func (l *TwoWayLinkedList) Set(index int, e interface{})

func (*TwoWayLinkedList) Size

func (l *TwoWayLinkedList) Size() int

func (*TwoWayLinkedList) String

func (l *TwoWayLinkedList) String() string

type TwoWayNode

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

Jump to

Keyboard shortcuts

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