Documentation
¶
Overview ¶
Package datastructure implements some data structure. eg. list, linklist, stack, queue, tree, graph.
Index ¶
- func ListToMap[T any, K comparable, V any](list *List[T], iteratee func(T) (K, V)) map[K]V
- type List
- func (l *List[T]) Cap() int
- func (l *List[T]) Clear()
- func (l *List[T]) Clone() *List[T]
- func (l *List[T]) Contain(value T) bool
- func (l *List[T]) Data() []T
- func (l *List[T]) DeleteAll(list *List[T]) bool
- func (l *List[T]) DeleteAt(index int)
- func (l *List[T]) DeleteIf(f func(T) bool) int
- func (l *List[T]) Difference(other *List[T]) *List[T]
- func (l *List[T]) Equal(other *List[T]) bool
- func (l *List[T]) ForEach(consumer func(T))
- func (l *List[T]) IndexOf(value T) int
- func (l *List[T]) IndexOfFunc(f func(T) bool) int
- func (l *List[T]) InsertAt(index int, value T)
- func (l *List[T]) InsertAtFirst(value T)
- func (l *List[T]) InsertAtLast(value T)
- func (l *List[T]) Intersection(other *List[T]) *List[T]
- func (l *List[T]) IsEmpty() bool
- func (l *List[T]) Iterator() iterator.Iterator[T]
- func (l *List[T]) LastIndexOf(value T) int
- func (l *List[T]) LastIndexOfFunc(f func(T) bool) int
- func (l *List[T]) Merge(other *List[T]) *List[T]
- func (l *List[T]) PopFirst() (*T, bool)
- func (l *List[T]) PopLast() (*T, bool)
- func (l *List[T]) Push(value T)
- func (l *List[T]) RetainAll(list *List[T]) bool
- func (l *List[T]) Reverse()
- func (l *List[T]) Size() int
- func (l *List[T]) SubList(fromIndex, toIndex int) *List[T]
- func (l *List[T]) Swap(i, j int)
- func (l *List[T]) SymmetricDifference(other *List[T]) *List[T]
- func (l *List[T]) Union(other *List[T]) *List[T]
- func (l *List[T]) Unique()
- func (l *List[T]) UpdateAt(index int, value T)
- func (l *List[T]) ValueOf(index int) (*T, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type List ¶
type List[T any] struct { // contains filtered or unexported fields }
List is a linear table, implemented with slice.
func (*List[T]) DeleteAll ¶
DeleteAll removes from this list all of its elements that are contained in the given list.
func (*List[T]) DeleteIf ¶
DeleteIf delete all satisfying f(data[i]), returns count of removed elements
func (*List[T]) Difference ¶
Difference returns the difference between two collections. return a list whose element in the original list, not in the given list.
func (*List[T]) ForEach ¶
func (l *List[T]) ForEach(consumer func(T))
ForEach performs the given action for each element of the list.
func (*List[T]) IndexOfFunc ¶
IndexOfFunc returns the first index satisfying f(v) if not found return -1.
func (*List[T]) InsertAtFirst ¶
func (l *List[T]) InsertAtFirst(value T)
InsertAtFirst insert value into list at first index.
func (*List[T]) InsertAtLast ¶
func (l *List[T]) InsertAtLast(value T)
InsertAtLast insert value into list at last index.
func (*List[T]) Intersection ¶
Intersection creates a new list whose element both be contained in list l and other.
func (*List[T]) Iterator ¶
Iterator returns an iterator over the elements in this list in proper sequence.
func (*List[T]) LastIndexOf ¶
LastIndexOf returns the index of the last occurrence of the value in this list. if not found return -1.
func (*List[T]) LastIndexOfFunc ¶
LastIndexOfFunc returns the index of the last occurrence of the value in this list satisfying f(data[i]) if not found return -1.
func (*List[T]) RetainAll ¶
RetainAll retains only the elements in this list that are contained in the given list.
func (*List[T]) SubList ¶
SubList returns a sub list of the original list between the specified fromIndex, inclusive, and toIndex, exclusive.
func (*List[T]) SymmetricDifference ¶
SymmetricDifference oppoiste operation of intersection function.
func (*List[T]) Union ¶
Union creates a new list contain all element in list l and other, remove duplicate element.