https://github.com/1995parham/linkedlist
The first generic linked list in go :dancer:
https://github.com/1995parham/linkedlist
generics go golang
Last synced: about 1 year ago
JSON representation
The first generic linked list in go :dancer:
- Host: GitHub
- URL: https://github.com/1995parham/linkedlist
- Owner: 1995parham
- License: gpl-3.0
- Created: 2021-08-22T20:09:17.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-02-17T06:28:30.000Z (over 1 year ago)
- Last Synced: 2025-04-12T19:53:25.612Z (about 1 year ago)
- Topics: generics, go, golang
- Language: Go
- Homepage:
- Size: 86.9 KB
- Stars: 31
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Linked List, in Go
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`.
```sh
go install golang.org/dl/gotip@latest
gotip download
```
then you can use the `gotip` command as your normal `go` command.
## Examples
```go
func main() {
l := list.New[int]()
l.PushFront(10)
l.PushFront(20)
l.PushFront(40)
fmt.Println(l)
}
```
```go
func main() {
l := list.New[string]()
l.PushFront("hello")
fmt.Println(l)
}
```
```go
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)
}
```
## Related Issues
-