This package provides a simple doubly-linked list with generics. The goal is to keep this package as simple as possible:
import "github.com/nitroshare/golist"
// Zero value for List is ready for use
l := &List[string]{}
// Add item (returning Element for newly inserted value)
e := l.Add("test")
// Show length of list
fmt.Printf("List length: %d\n", l.Len)
// Iterate over items
for e := l.Front; e != nil; e = e.Next {
fmt.Println(e.Value)
// Remove an item during iteration
l.Remove(e)
// e.Next will still point to what was going to be the next item
}
// Remove and return the first element (useful for a queue)
e := l.PopFront()
// Remove and return the last element (useful for a stack)
e := l.PopBack()