Documentation
¶
Index ¶
- type LinkedList
- func (list *LinkedList) Add(val interface{})
- func (list *LinkedList) Contains(val interface{}) bool
- func (list *LinkedList) ForEach(consumer func(int, interface{}) bool)
- func (list *LinkedList) Get(index int) (val interface{})
- func (list *LinkedList) Insert(index int, val interface{})
- func (list *LinkedList) Len() int
- func (list *LinkedList) Range(start int, stop int) []interface{}
- func (list *LinkedList) Remove(index int) (val interface{})
- func (list *LinkedList) RemoveAllByVal(val interface{}) int
- func (list *LinkedList) RemoveByVal(val interface{}, count int) int
- func (list *LinkedList) RemoveLast() (val interface{})
- func (list *LinkedList) ReverseRemoveByVal(val interface{}, count int) int
- func (list *LinkedList) Set(index int, val interface{})
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 (*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]