https://github.com/clickermonkey/dsa
A Go module with my common data structures and algorithms.
https://github.com/clickermonkey/dsa
Last synced: 7 months ago
JSON representation
A Go module with my common data structures and algorithms.
- Host: GitHub
- URL: https://github.com/clickermonkey/dsa
- Owner: ClickerMonkey
- License: mit
- Created: 2025-04-28T12:53:20.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-05-29T23:48:02.000Z (9 months ago)
- Last Synced: 2025-06-29T21:37:17.349Z (8 months ago)
- Language: Go
- Size: 83 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dsa
A Go module with my common data structures and algorithms.
> go get github.com/clickermonkey/dsa
### Interfaces
- `dsa.Stack[T]` a stack interface (FILO/LIFO)
- `dsa.Queue[T]` a queue interface (FIFO/LILO)
### Concrete
- `dsa.LinkedList[T]` a doubly linked list of T values. non-sequential memory layout but O(1) insertion & removal. Implements stack & queue.
- `dsa.LinkedNode[T]` a doubly linked list node.
- `dsa.Circle[T]` a size bounded stack & queue.
- `dsa.PriorityQueue[T]` a queue where highest priority value is in the front.
- `dsa.WaitQueue[T]` a concurrent queue implementation where `Dequeue()` waits for a value.
- `dsa.ReadyQueue[T]` a concurrent priority queue implementation where dequeue waits for a value which meets an expected priority (ready state).
- `dsa.SyncQueue[T]` a conccurrent queue wrapper.
- `dsa.SliceStack[T]` a slice stack implementation.
- `dsa.WaitStack[T]` a concurrent stack implementation where `Pop()` waits for a value.
- `dsa.SyncStack[T]` a concurrent stack wrapper.
### Helpers
- `dsa.Stopper` a wait/stop object to simplify gates across goroutines.
### Functions
- `dsa.After(fn)` converts a function call into a channel that resolves when the function returns.
- `dsa.ToChannel(fn)` converts a function which returns a value into a channel which resolves that value when the function returns it.
- `dsa.WorkerPool(ctx,n,q,do)` creates an async pool of workers which do work off of a queue which can be stopped at any time.
- `dsa.Executor(ctx,q,do)` creates an async work processor from a queue of work that can be stopped at any time.