Documentation ¶
Index ¶
- type EnumerableWithIndex
- type Iterator
- type List
- func (l *List[T]) Add(values ...T)
- func (l *List[T]) All(f func(index int, value T) bool) bool
- func (l *List[T]) Any(f func(index int, value T) bool) bool
- func (l *List[T]) Append(values ...T)
- func (l *List[T]) Clear()
- func (l *List[T]) Contains(values ...T) bool
- func (l *List[T]) Each(f func(index int, value T))
- func (l *List[T]) Empty() bool
- func (l *List[T]) Filter(f func(index int, value T) bool) *List[T]
- func (l *List[T]) Find(f func(index int, value T) bool) (_ int, t T)
- func (l *List[T]) FromJSON(data []byte) error
- func (l *List[T]) Get(i int) (t T, _ bool)
- func (l *List[T]) IndexOf(value T) int
- func (l *List[T]) Insert(i int, values ...T)
- func (l *List[T]) Iterator() *Iterator[T]
- func (l *List[T]) Prepend(values ...T)
- func (l *List[T]) Remove(i int) (t T, _ bool)
- func (l *List[T]) Set(i int, value T)
- func (l *List[T]) Size() int
- func (l *List[T]) Sort(c utils.Comparator[T])
- func (l *List[T]) String() string
- func (l *List[T]) Swap(i, j int)
- func (l *List[T]) ToJSON() ([]byte, error)
- func (l *List[T]) Values() []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnumerableWithIndex ¶
type EnumerableWithIndex[T comparable] interface { // Filter returns a new container containing all elements for which the given function returns a true value. Filter(func(index int, value T) bool) *List[T] containers.EnumerableWithIndex[T] }
type Iterator ¶
type Iterator[T comparable] struct { // contains filtered or unexported fields }
Iterator represents a forward iterator of a DoubleLinkedList.
func (*Iterator[T]) Begin ¶
func (it *Iterator[T]) Begin()
Begin resets the iterator to its initial state.
func (*Iterator[T]) End ¶
func (it *Iterator[T]) End()
End moves the iterator past the last element in the list.
func (*Iterator[T]) First ¶
First moves the iterator to the first element and returns true if there was a first element in the iteration.
func (*Iterator[T]) Last ¶
Last moves the iterator to the last element and returns true if there was a last element in the iteration.
type List ¶
type List[T comparable] struct { // contains filtered or unexported fields }
func Map ¶
func Map[K comparable, V comparable](l *List[K], f func(index int, value K) V) *List[V]
Map invokes the given function once for each element and returns a container containing the values returned by the given function.
func (*List[T]) All ¶
All passes each element of the container to the given function and returns true if the function returns true for all elements.
func (*List[T]) Any ¶
Any passes each element of the container to the given function and returns true if the function ever returns true for any element.
func (*List[T]) Append ¶
func (l *List[T]) Append(values ...T)
Append adds values to the end of the list.
func (*List[T]) Each ¶
Each calls the given function once for each element, passing that element's index and value.
func (*List[T]) Filter ¶
Filter returns a new container containing all elements for which the given function returns a true value.
func (*List[T]) Find ¶
Find passes each element of the container to the given function and returns the first (index,value) for which the function is true or -1,nil otherwise if no element matches the criteria.
func (*List[T]) Prepend ¶
func (l *List[T]) Prepend(values ...T)
Prepend adds values to the beginning of the list.