Skip to content
This repository was archived by the owner on Jul 26, 2026. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

golist

Build Status Coverage Status Go Reference MIT License

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()

About

Simple doubly-linked list with generics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages