list

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: May 18, 2021 License: GPL-3.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 LinkedList

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

LinkedList is doubly linked list

func Make

func Make(vals ...interface{}) *LinkedList

Make creates a new linked list

func (*LinkedList) Add

func (list *LinkedList) Add(val interface{})

Add adds value to the tail

func (*LinkedList) Contains

func (list *LinkedList) Contains(val interface{}) bool

Contains returns whether the given value exist in the list

func (*LinkedList) ForEach

func (list *LinkedList) ForEach(consumer func(int, interface{}) bool)

ForEach visits each element in the list if the consumer returns false, the loop will be break

func (*LinkedList) Get

func (list *LinkedList) Get(index int) (val interface{})

Get returns value at the given index

func (*LinkedList) Insert

func (list *LinkedList) Insert(index int, val interface{})

Insert inserts value at the given index, the original element at the given index will move backward

func (*LinkedList) Len

func (list *LinkedList) Len() int

Len returns the number of elements in list

func (*LinkedList) Range

func (list *LinkedList) Range(start int, stop int) []interface{}

Range returns elements which index within [start, stop)

func (*LinkedList) Remove

func (list *LinkedList) Remove(index int) (val interface{})

Remove removes value at the given index

func (*LinkedList) RemoveAllByVal

func (list *LinkedList) RemoveAllByVal(val interface{}) int

RemoveAllByVal removes all elements with the given val

func (*LinkedList) RemoveByVal

func (list *LinkedList) RemoveByVal(val interface{}, count int) int

RemoveByVal removes at most `count` values of the specified value in this list scan from left to right

func (*LinkedList) RemoveLast

func (list *LinkedList) RemoveLast() (val interface{})

RemoveLast removes the last element and returns its value

func (*LinkedList) ReverseRemoveByVal

func (list *LinkedList) ReverseRemoveByVal(val interface{}, count int) int

ReverseRemoveByVal removes at most `count` values of the specified value in this list scan from right to left

func (*LinkedList) Set

func (list *LinkedList) Set(index int, val interface{})

Set updates value at the given index, the index should between [0, list.size]

Jump to

Keyboard shortcuts

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