Juniper is an extension to the Go standard library using generics, including containers, iterators, and streams.

Overview

Juniper

Go Reference Go 1.18 Fuzz

Juniper is a library of extensions to the Go standard library using generics, including containers, iterators, and streams.

  • container/tree contains a Map and Set that keep elements in sorted order. They are implemented using a B-tree, which performs better than a binary search tree.
  • container/deque contains a double-ended queue implemented with a ring buffer.
  • container/xheap contains a min-heap similar to the standard library's container/heap but more ergonomic, along with a PriorityQueue that allows setting priorities by key.
  • container/xlist contains a linked-list similar to the standard library's container/list, but type-safe.
  • xslices contains some commonly-used slice operations, like Insert, Remove, Chunk, Filter, and Compact.
  • iterator contains an iterator interface used by the containers, along with functions to manipulate them, like Map, While, and Reduce.
  • stream contains a stream interface, which is an iterator that can fail. Useful for iterating over collections that require I/O. It has most of the same combinators as iterator, plus some extras like Pipe and Batch.
  • parallel contains some shorthand for common uses of goroutines to process slices, iterators, and streams in parallel, like parallel.MapStream.
  • xsort contains extensions to the standard library package sort. Notably, it also has the definition for xsort.Less, which is how custom orderings can be defined for sorting and also for ordered collections like from container/tree.
  • You can probably guess what's in the packages sets, xerrors, xmath, xmath/xrand, xsync, and xtime.

Packages that overlap directly with a standard library package are named the same but with an x prefix for "extensions", e.g. sort and xsort. xslices is named so because a slices package is planned for Go 1.19.

See the docs for more.

Status

Things should basically work. The container packages have been tested decently well using the new built-in coverage-based fuzzer (it's a pleasure, by the way, other than having to translate from the built-in fuzz argument types). container/tree has been benchmarked and tweaked for some extra performance. It's far from hyper-optimized, but should be efficient enough. Most of the simpler functions are tested only with their examples.

Since I no longer work at a megacorp running a huge global deployment of Go, I no longer have that at my disposal to certify any of this as battle-hardened. However, the quality of code here is high enough that I would've been comfortable using anything here in the systems that I worked on.

Issues
  • Feature Request: Group By function?

    Feature Request: Group By function?

    It would be nice to have a Group-By function for collections like https://www.scala-lang.org/api/2.12.7/scala/collection/Iterable.html#groupByK:scala.collection.immutable.Map[K,Repr] or (in Go before generics): https://github.com/ahmetb/go-linq/blob/master/groupby.go

    opened by StevenACoffman 4
  • impossible to use tree.Range

    impossible to use tree.Range

    tree.Range requests Bound as parameters, but for making Bound there is no access to type boundType and its values. The most usefull b-tree search functions are inaccessible due names without reason.

    opened by Claus1 0
  • Benchmark - compared to std library

    Benchmark - compared to std library

    It would be good to see benchmarks with std lib such suite would help improve the library. I can help with that if the author of this project is willing to drive the project on this direction.

    opened by prassee 1
Owner
Braden Walker
Infrastructure, distributed systems, databases.
Braden Walker
Package iter provides generic, lazy iterators, functions for producing them from primitive types, as well as functions and methods for transforming and consuming them.

iter Package iter provides generic, lazy iterators, functions for producing them from primitive types, as well as functions and methods for transformi

Matthew Toohey 24 Jun 7, 2022
Go implementation of C++ STL iterators and algorithms.

iter Go implementation of C++ STL iterators and algorithms. Less hand-written loops, more expressive code. README translations: 简体中文 Motivation Althou

disksing 157 Jun 15, 2022
Collection library using generics in Go

Collection Collection library using generics in Go Overview This is a library to provide useful collection data structures and methods for Gophers. Th

Hidetatz Yaginuma 10 Jun 16, 2022
Probabilistic data structures for processing continuous, unbounded streams.

Boom Filters Boom Filters are probabilistic data structures for processing continuous, unbounded streams. This includes Stable Bloom Filters, Scalable

Tyler Treat 1.5k Jun 30, 2022
Go iter tools (for iterating , mapping, filtering, reducing streams -represented as channels-)

Go iter tools (for iterating , mapping, filtering, reducing streams -represented as channels-)

Hulne 12 Jun 2, 2022
Collections for Golang using generics. Currently containing Hash Set.

Implementation of missing colections for Golang using Generics. Free of dependencies. Curently in early development phase. Requirements Go 1.18+ Insta

Vinícius Ferreira 0 Dec 30, 2021
💯 Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving

Package validator implements value validations for structs and individual fields based on tags.

Flamego 12 Feb 16, 2022
Convert arbitrary formats to Go Struct (including json, toml, yaml, etc.)

go2struct Convert arbitrary formats to Go Struct (including json, toml, yaml, etc.) Installation Run the following command under your project: go get

Afeyer 33 Jun 9, 2022
Clone a directory (including permissions) into S3 for File Gateway usage

s3-tree-clone Clone a filesystem tree to S3 (including metadata), skipping over files that are already synced, in a manner compatible with AWS File Ga

David Cuthbert 1 Dec 2, 2021
Generic types that are missing from Go, including sets, trees, sorted lists, etc.

go-typ Generic types that are missing from Go, including sets, trees, sorted lists, etc. All code is implemented with 0 dependencies and in pure Go co

null 12 Jul 3, 2022
A Go library to iterate over potentially nested map keys using the visitor pattern

A Go library to iterate over potentially nested map keys using the visitor pattern

null 3 Mar 15, 2022
Some data structures and algorithms using golang

Some data structures and algorithms using golang

null 57 Apr 12, 2022
Golang string comparison and edit distance algorithms library, featuring : Levenshtein, LCS, Hamming, Damerau levenshtein (OSA and Adjacent transpositions algorithms), Jaro-Winkler, Cosine, etc...

Go-edlib : Edit distance and string comparison library Golang string comparison and edit distance algorithms library featuring : Levenshtein, LCS, Ham

Hugo Bollon 331 Jun 29, 2022
Multi-String Pattern Matching Algorithm Using TrieHashNode

Multi-String Pattern Matching algorithm. This implementation is inspired from Aho-Corasick algorithm Getting Started modelA = mspm.NewModel("mspm_mode

Sujit Shakya 17 Jan 23, 2022
Pipelines using goroutines

pipeline This package provides a simplistic implementation of Go pipelines as outlined in Go Concurrency Patterns: Pipelines and cancellation. Docs Go

Nikhil Mungel 39 Apr 4, 2022
A simple Set data structure implementation in Go (Golang) using LinkedHashMap.

Set Set is a simple Set data structure implementation in Go (Golang) using LinkedHashMap. This library allow you to get a set of int64 or string witho

Studio Sol Comunicação Digital Ltda 21 Apr 6, 2022
High-performance minimalist queue implemented using a stripped-down lock-free ringbuffer, written in Go (golang.org)

This project is no longer maintained - feel free to fork the project! gringo A high-performance minimalist queue implemented using a stripped-down loc

Darren Elwood 126 Jun 8, 2022
Go framework to simplify CRUD of structured data using Graph operations

gocrud Go framework to simplify creating, reading, updating, and deleting arbitrary depth structured data — to make building REST services fast and ea

Manish R Jain 314 Jun 28, 2022
A typed implementation of the Go sync.Map using code generation

syncmap A typed implementation of the Go sync.Map using code generation. Install go get -u github.com/a8m/[email protected] Examples: Using CLI $ syncma

Ariel Mashraki 233 Jun 30, 2022