Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
github.com/matej-chmel/go-linked-list
Generic library for singly and doubly linked lists.
go get github.com/Matej-Chmel/go-linked-list@v1.0.3
package main
import (
"fmt"
lk "github.com/Matej-Chmel/go-linked-list"
)
func main() {
// Easy construction
singleHead := lk.CreateSinglyLinkedList(1, 2, 3)
doubleHead := lk.CreateDoublyLinkedList[int8](10, 20, 30)
// Conversion to string
fmt.Println(singleHead)
fmt.Println(doubleHead)
node := singleHead
sum := 0
for node != nil {
// Each node has Next and Val fields
sum += node.Val
node = node.Next
}
fmt.Println("Sum:", sum)
// Doubly linked list can be iterated backwards
current := doubleHead.GetLast()
total := int8(0)
for current != nil {
total += current.Val
current = current.Prev
}
fmt.Println("Total:", total)
// Conversion to string can be customized
symbols := lk.NewFormatSymbols(true)
symbols.Start = "("
symbols.Sep = ", "
symbols.End = ")"
fmt.Println(singleHead.Format(symbols))
}
[1 > 2 > 3]
[10 <> 20 <> 30]
Sum: 6
Total: 60
(1, 2, 3)
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.