A Go (Golang) generic data structures library featuring concurrency-safe and performant implementations of:
- ✅ Priority Queue (heap-based)
- ✅ Concurrency-safe Doubly Linked List
- ✅ Queue (FIFO)
- ✅ Stack (LIFO)
- ✅ Primitive-specific helper functions for performance and convenience
- ✅ Set (ensures all elements are unique).
Built using Go generics, ensuring type safety without sacrificing performance.
- Heap-based Min/Max Priority Queue.
- Supports custom comparators.
- Primitive-specific constructors:
int
,int8
,int16
,int32
,int64
float32
,float64
string
- Doubly Linked List implementation.
- Concurrency-safe using fine-grained locking.
- Generic FIFO queue built on top of the concurrency-safe list.
- Primitive-specific factory functions:
int
,int8
,int16
,int32
,int64
float32
,float64
string
,rune
,byte
- Generic LIFO stack built on top of the concurrency-safe list.
- Primitive-specific factory functions:
int
,int8
,int16
,int32
,int64
float32
,float64
string
,rune
,byte
- Generic implementation of a mathematical set.
- Backed by a
map[T]struct{}
for efficient lookups. - Guarantees uniqueness of elements.
- APIs:
Add(value T)
Remove(value T)
Contains(value T) bool
Size() int
Empty() bool
Clear()
Values() []T
IsEmpty()
Size()
Clear()
- Type-specific access methods (
Front
,Back
,Top
,Pop
,Push
)
go get github.com/ckshitij/collection
import "github.com/ckshitij/collection/pq"
pq := pq.NewMinIntPQ(5, 3, 8)
pq.Push(2)
min := pq.Pop() // min == 2
import "github.com/ckshitij/collection/queue"
q := queue.NewIntQueue(1, 2, 3)
q.Enqueue(4)
front := q.Front() // front == 1
_ = q.Dequeue()
import "github.com/ckshitij/collection/stack"
st := stack.NewIntStack(10, 20, 30)
top := st.Top() // top == 30
_ = st.Pop()
import "github.com/ckshitij/collection/list"
lst := list.NewList[int]()
lst.PushFront(10)
lst.PushBack(20)
size := lst.Len()
We welcome contributions! To contribute:
- Fork the repository.
- Create a feature/bugfix branch.
- Add your changes with appropriate tests.
- Ensure all tests pass:
go test ./... -race -cover
- Submit a Pull Request with a clear description.
- Follow idiomatic Go practices.
- Ensure >90% test coverage for all new features.
- Maintain existing naming conventions and structure.
This project is licensed under the MIT License.