Skip to content

Most commonly used utility/helper functions for generic types in Go.

License

Notifications You must be signed in to change notification settings

akshaybharambe14/gouf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GOUF - Utility Functions for generic types

Go team released Go 1.18 beta recently with support for Generics(a.k.a type parameters). This package provides much needed and frequently used utility functions for generic data types.

Supported Operations

Slices

  • All - Check if all elements in a slice satisfy a condition
  • Any - Check if any element in a slice satisfies a condition
  • Check - Check if slice can accept a given indices
  • Count - count all elements in a slice that satisfy a condition
  • Delete - Delete element at given index
  • DeleteUnordered - Delete element at given index, without preserving order(efficient than Delete)
  • DeleteFn - Delete element that satisfies a condition
  • DeletePlaces - Delete elements at given indices
  • Filter - Filter elements in a slice that satisfy a condition
  • FilterInPlace - Filter elements in a slice that satisfy a condition without allocating new slice(efficient than Filter)
  • FilterInPlaceGC - Filter elements in a slice that satisfy a condition without allocating new slice and zeroing wanted elements(efficient than Filter)
  • FindFn - Find element in a slice(for comparable types)
  • FindFn - Find element in a slice that satisfies a condition
  • Map - Map elements in a slice
  • Reduce - Reduce elements in a slice to a single value
  • Sum - Sum all elements in a slice (for numeric/string types)
  • SumFn - Sum all elements in a slice that satisfy a condition(for custom types)
  • Unique - Remove duplicate elements in a slice (for comparable types)
  • UniqueFn - Remove duplicate elements in a slice that satisfy a condition(for custom types)
  • UniqueInPlace - Remove duplicate elements in a slice without allocating new slice(efficient than Unique)
  • UniqueFnInPlace - Remove duplicate elements in a slice without allocating new slice(efficient than UniqueFn)

And a lot more(in pipeline).

Maps

TBD

Want to contribute?

see guide.

Contact

Akshay Bharambe

Feedback

This is very much important to improve this package. Do let me know if you have any feedback. Leave a ⭐ if you find this helpful.

About

Most commonly used utility/helper functions for generic types in Go.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages