All Projects → changkun → generics

changkun / generics

Licence: BSD-3-Clause license
Deprecated! See https://github.com/golang-design/go2generics.

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to generics

Ply
Painless polymorphism
Stars: ✭ 117 (+350%)
Mutual labels:  generics
Staticvec
Implements a fixed-capacity stack-allocated Vec alternative backed by an array, using const generics.
Stars: ✭ 236 (+807.69%)
Mutual labels:  generics
rust-amplify
Amplifying Rust language capabilities: multiple generic trait implementations, type wrappers, bit-precise numerics, derive macros
Stars: ✭ 38 (+46.15%)
Mutual labels:  generics
Envy
😠 Environmentally friendly environment variables
Stars: ✭ 132 (+407.69%)
Mutual labels:  generics
Higgledy
Higher-kinded data via generics
Stars: ✭ 153 (+488.46%)
Mutual labels:  generics
Gengen
A Go source transformation tool for generics
Stars: ✭ 253 (+873.08%)
Mutual labels:  generics
Miniboxing Plugin
Miniboxing is a program transformation that improves the performance of Scala generics when used with primitive types. It can speed up generic collections by factors between 1.5x and 22x, while maintaining bytecode duplication to a minimum. You can easily add miniboxing to your sbt project:
Stars: ✭ 106 (+307.69%)
Mutual labels:  generics
Java-Programs
Java Practiced Problems including concepts of OOPS, Interface, String , Collection.
Stars: ✭ 51 (+96.15%)
Mutual labels:  generics
Syncmap
A typed implementation of the Go sync.Map using code generation
Stars: ✭ 200 (+669.23%)
Mutual labels:  generics
go-ringbuf
Lock-free MPMC Ring Buffer (Generic) for SMP, in golang. Some posts in chinese:
Stars: ✭ 43 (+65.38%)
Mutual labels:  generics
Gomacro
Interactive Go interpreter and debugger with REPL, Eval, generics and Lisp-like macros
Stars: ✭ 1,784 (+6761.54%)
Mutual labels:  generics
Auth Adt
Authenticated Data Structures Generically
Stars: ✭ 150 (+476.92%)
Mutual labels:  generics
go-generics
Go的泛型文档、代码、讨论
Stars: ✭ 43 (+65.38%)
Mutual labels:  generics
Go Generics Example
Example code for Go generics
Stars: ✭ 121 (+365.38%)
Mutual labels:  generics
async
Synchronization and asynchronous computation package for Go
Stars: ✭ 104 (+300%)
Mutual labels:  generics
Promis
The easiest Future and Promises framework in Swift. No magic. No boilerplate.
Stars: ✭ 110 (+323.08%)
Mutual labels:  generics
Arrow Meta
Functional companion to Kotlin's Compiler
Stars: ✭ 246 (+846.15%)
Mutual labels:  generics
parco
🏇🏻 generalist, fast and tiny binary parser and compiler generator, powered by Go 1.18+ Generics
Stars: ✭ 57 (+119.23%)
Mutual labels:  generics
Java-Interview-Programs
Core Java Projects with complete source code
Stars: ✭ 48 (+84.62%)
Mutual labels:  generics
lancet
A comprehensive, efficient, and reusable util function library of go.
Stars: ✭ 2,228 (+8469.23%)
Mutual labels:  generics

Deprecated! See golang-design/go2generics.

This package shows an implementation outlook of proposed generics APIs.

import "changkun.de/x/generics"
go test -gcflags=-G=3 ./... -count=1 -v

From Go team:

  • golang/go#45458 proposal: constraints: new package to define standard type parameter constraints
  • golang/go#47319 proposal: constraints: new package to define standard type parameter constraints (discussion)
  • golang/go#45955 proposal: slices: new package to provide generic slice functions
  • golang/go#47203 proposal: slices: new package to provide generic slice functions (discussion)
  • golang/go#47331 proposal: container/set: new package to provide a generic set type (discussion)
  • golang/go#47649 proposal: maps: new package to provide generic map functions
  • golang/go#47330 proposal: maps: new package to provide generic map functions (discussion)
  • golang/go#47657 proposal: sync, sync/atomic: add PoolOf, MapOf, ValueOf

From community:

constraints

// Package constraints defines a set of useful constraints to be used with type parameters.
package constraints

type Signed interface { ... }
type Unsigned interface { ... }
type Integer interface { ... }
type Float interface { ... }
type Complex interface { ... }
type Ordered interface { ... }
type Slice[Elem any] interface { ... }
type Map[K, V any] interface { ... }
type Chan[T any] interface { ... }

slices

// Package slices defines various functions useful with slices of any type.
// Unless otherwise specified, these functions all apply to the elements
// of a slice at index 0 <= i < len(s).
package slices

import "constraints"

func Equal[T comparable](s1, s2 []T) bool
func EqualFunc[T1, T2 any](s1 []T1, s2 []T2, eq func(T1, T2) bool) bool
func Compare[T constraints.Ordered](s1, s2 []T) int
func CompareFunc[T any](s1, s2 []T, cmp func(T, T) int) int
func Index[T comparable](s []T, v T) int
func IndexFunc[T any](s []T, f func(T) bool) int
func Contains[T comparable](s []T, v T) bool
func Insert[S constraints.Slice[T], T any](s S, i int, v ...T) S
func Delete[S constraints.Slice[T], T any](s S, i, j int) S
func Clone[S constraints.Slice[T], T any](s S) S
func Compact[S constraints.Slice[T], T comparable](s S) S
func CompactFunc[S constraints.Slice[T], T any](s S, cmp func(T, T) bool) S
func Grow[S constraints.Slice[T], T any](s S, n int) S
func Clip[S constraints.Slice[T], T any](s S) S

maps

// Package maps defines various functions useful with maps of any type.
package maps

func Keys[K comparable, V any](m map[K]V) []K
func Values[K comparable, V any](m map[K]V) []V
func Equal[K, V comparable](m1, m2 map[K]V) bool
func EqualFunc[K comparable, V1, V2 any](m1 map[K]V1, m2 map[K]V2, cmp func(V1, V2) bool) bool
func Clear[K comparable, V any](m map[K]V)
func Clone[K comparable, V any](m map[K]V) map[K]V
func Add[K comparable, V any](dst, src map[K]V)
func Filter[K comparable, V any](m map[K]V, keep func(K, V) bool)

container/set

// Package set defines a Set type that holds a set of elements.
package set

type Set[Elem comparable] struct { ... }
func (s *Set[Elem]) Add(v ...Elem)
func (s *Set[Elem]) AddSet(s2 Set[Elem])
func (s *Set[Elem]) Remove(v ...Elem)
func (s *Set[Elem]) RemoveSet(s2 Set[Elem])
func (s *Set[Elem]) Has(v Elem) bool
func (s *Set[Elem]) HasAny(s2 Set[Elem]) bool
func (s *Set[Elem]) HasAll(s2 Set[Elem]) bool
func (s *Set[Elem]) Values() []Elem
func (s *Set[Elem]) Equal(s2 Set[Elem]) bool
func (s *Set[Elem]) Clear()
func (s *Set[Elem]) Clone() Set[Elem]
func (s *Set[Elem]) Filter(keep func(Elem) bool)
func (s *Set[Elem]) Len() int
func (s *Set[Elem]) Do(f func(Elem) bool)

func Of[Elem comparable](v ...Elem) Set[Elem]
func Union[Elem comparable](s1, s2 Set[Elem]) Set[Elem]
func Intersection[Elem comparable](s1, s2 Set[Elem]) Set[Elem]
func Difference[Elem comparable](s1, s2 Set[Elem]) Set[Elem]

License

Copyright © 2021 Changkun Ou, release under BSD 3-Clause License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].