linked_list

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FoldLeft

func FoldLeft[A, B any](l *LinkedList[A], z B, f func(B, A) B) B

func FoldRight

func FoldRight[A, B any](l *LinkedList[A], z B, f func(A, B) B) B
func Head[T any](l *LinkedList[T]) T

TODO Head of Nil list will throw a NPE. Fix this

func Len

func Len[T any](l *LinkedList[T]) int

func ToArray

func ToArray[A any](l *LinkedList[A]) []A

Types

type LinkedList

type LinkedList[T any] struct {
	// contains filtered or unexported fields
}

func AddLast

func AddLast[T any](h T, l *LinkedList[T]) *LinkedList[T]

func AddWhile

func AddWhile[T any](l *LinkedList[T], p func(T) bool) *LinkedList[T]

Evaluates elements of given list, adding elements to head of a new list until predicate returns false, returning the new list and preserving ordering of original list. Note that this is different than filter. The algorithm stops appending to the resulting list when the predicate returns false.

func Drop

func Drop[T any](l *LinkedList[T], n int) *LinkedList[T]

func Filter

func Filter[T any](l *LinkedList[T], p func(T) bool) *LinkedList[T]

Evaluates elements of given list and filters out those elements which fail predicate, preserving order of original list.

func Push

func Push[T any](h T, l *LinkedList[T]) *LinkedList[T]

func Tail

func Tail[T any](l *LinkedList[T]) (*LinkedList[T], error)

func ToList

func ToList[T any](xs []T) *LinkedList[T]

func Zero

func Zero[T any]() *LinkedList[T]

func (*LinkedList[T]) String

func (w *LinkedList[T]) String() string

Jump to

Keyboard shortcuts

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