linkedlist

package module
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 1 Imported by: 0

README

Go Reference Go Version

Linked List in Go

A simple Linked List implementation written in Go for study purposes.

This repository is part of my journey learning data structures and algorithms using Go. The goal is to understand how linked lists work internally by implementing them from scratch, without relying on Go's standard library implementations.

Note: This project is intended for educational purposes and is not designed to be a production-ready library.

Features

Currently implemented:

  • ✅ Singly Linked List
  • ✅ Insert elements
  • ✅ Remove elements
  • ✅ Search elements
  • ✅ Traverse the list
  • ✅ Support for Go Generics

Roadmap

Planned improvements include:

  • Doubly Linked List
  • Circular Linked List
  • Iterators
  • ✅ More utility methods
  • Benchmarks
  • Unit tests
  • Documentation with complexity analysis
  • Stack
  • Queue
  • Tree
  • Iterators

Project Structure

.
├── linkedlist.go
├── node.go
├── go.mod
├── LICENSE
└── README.md

Complexity

Operation Time
Search O(n)
Insert (head) O(1)
Insert (tail) O(1)
Insert (after) O(n)
Delete O(n)
Find O(n)
Values O(n)

Future

The current implementation supports Go Generics, making the linked list reusable with any type. Soon new methods will be created to allow search and deletion by value.

License

This project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LinkedList

type LinkedList[T comparable] struct {
	// contains filtered or unexported fields
}

func New

func New[T comparable]() *LinkedList[T]

func (*LinkedList[T]) Append

func (ll *LinkedList[T]) Append(val ...T)

func (*LinkedList[T]) Clear added in v0.2.0

func (ll *LinkedList[T]) Clear()

func (*LinkedList[T]) Delete

func (ll *LinkedList[T]) Delete(target *Node[T]) bool

func (*LinkedList[T]) Find

func (ll *LinkedList[T]) Find(val T) *Node[T]

Find searches for the first node containing val. It returns nil if the value is not present in the list.

func (*LinkedList[T]) Head

func (ll *LinkedList[T]) Head() *Node[T]

func (*LinkedList[T]) InsertAfter

func (ll *LinkedList[T]) InsertAfter(target *Node[T], val T) error

func (*LinkedList[T]) IsEmpty

func (ll *LinkedList[T]) IsEmpty() bool

func (*LinkedList[T]) Len

func (ll *LinkedList[T]) Len() int

func (*LinkedList[T]) Present added in v0.2.2

func (ll *LinkedList[T]) Present(val T) bool

func (*LinkedList[T]) PushBack

func (ll *LinkedList[T]) PushBack(val T)

func (*LinkedList[T]) PushFront

func (ll *LinkedList[T]) PushFront(val T)

func (*LinkedList[T]) Tail

func (ll *LinkedList[T]) Tail() *Node[T]

func (*LinkedList[T]) Values

func (ll *LinkedList[T]) Values() []T

type Node

type Node[T comparable] struct {
	// contains filtered or unexported fields
}

func (*Node[T]) Next

func (node *Node[T]) Next() *Node[T]

func (*Node[T]) Value

func (n *Node[T]) Value() T

Jump to

Keyboard shortcuts

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