https://github.com/khavishbhundoo/collections
A collection of common data structures for Go in both thread safe and non-thread safe variants
https://github.com/khavishbhundoo/collections
conccurent data-structures golang map queue stack
Last synced: 2 months ago
JSON representation
A collection of common data structures for Go in both thread safe and non-thread safe variants
- Host: GitHub
- URL: https://github.com/khavishbhundoo/collections
- Owner: khavishbhundoo
- License: mit
- Created: 2025-08-30T07:49:26.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-09-14T15:56:04.000Z (6 months ago)
- Last Synced: 2025-09-14T17:41:58.334Z (6 months ago)
- Topics: conccurent, data-structures, golang, map, queue, stack
- Language: Go
- Homepage:
- Size: 90.8 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pkg.go.dev/github.com/khavishbhundoo/collections)
# Collections
A collection of common data structures for Go in both thread safe and non-thread safe variants.The documentation,
example usage are available in their own dedicated page. [Benchmark](benchmark/benchmark.txt) results are available for
all the data structures.
## Installation
```bash
go get -u github.com/khavishbhundoo/collections
```
## Design Principles
- General-Purpose Design
These data structures are designed to perform well enough across a wide range of use cases rather than being optimized
for a type of operation.
- Zero-Value Usability
All data structures are immediately usable without explicit initialization.
For example, `var q Queue[int]` is valid and ready to accept elements.
- Explicit Construction
Constructors are provided for flexibility:
`New` creates a structure with default capacity.
`NewWithCapacity` allows pre-allocation when the expected size is known.
- Efficient Memory Management
Slice-backed structures (e.g. Stack, Queue) grow automatically and shrink when appropriate to reclaim memory, minimizing
long-term footprint.
- Concurrency by Design
Concurrent variants are built with minimal locking to ensure safety across goroutines while prioritizing throughput and
reducing contention.
## Non Thread safe
[Stack](stack/)
[Queue](queue/)
[Set](set/)
## Thread safe
[Stack](concurrent/stack/)
[Queue](concurrent/queue/)
[Set](concurrent/set/)
[CMap](concurrent/cmap/)