linkedlist

command module
v0.0.0-...-c92c33a Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

README

Linked List, in Go

GitHub Workflow Status GitHub go.mod Go version (subdirectory of monorepo) Codecov

As you know generics will come to go 1.18 and one of the major drawbacks in go was implementing data structure because of the lack of generics. I implemented a small generic linked list in go and I think we can start having brand new data structures in Go.

gotip

First of all you need to install the master version of golang and for this you can use gotip.

go install golang.org/dl/gotip@latest
gotip download

then you can use the gotip command as your normal go command.

Examples

func main() {
        l := list.New[int]()

        l.PushFront(10)
        l.PushFront(20)
        l.PushFront(40)

        fmt.Println(l)
}
func main() {
        l := list.New[string]()

        l.PushFront("hello")

        fmt.Println(l)
}
func main() {
        l := list.New[int]()

        l.PushFront(10)
        l.PushFront(20)
        l.PushFront(40)
        l.PushFront(42)

        fmt.Println(l)

        s := l.Filter(func(i int) bool {
                return i%10 == 0
        })

        fmt.Println(s)
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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