Golang collection types using Generics. Also includes common collection operations for existing types like slices.
A unique set of Comparable
values. Set
's are useful for quickly getting the
unique values of a slice and performing set operations such as
Difference
Union
Intersection
Complement
There are also utility functions for using set operations with slices. These
helpers follow the syntax SliceUnion
, SliceIntersection
, etc.
A map that contains the counts of Comparable
items. Counters can be created
from
- Maps where the value is an int.
- Slice where the number of times an item is repeated is the count.
- String where each character is parsed as an item.
Some useful methods of counters include
MostCommon
- get the most common elementMostCommonN
- get the N most common elementsAddCounter
/SubtractCounter
- add/subtract one counter from another
Slices are a built in type in Go, but this package includes some utility functions for slices that are not built in. These include:
Unique
- get the unique values of a sliceContains
- check if a slice contains a valueFilter
- filter a slice based on a predicateIndexOf
- get the index of a value in a sliceMap
- apply a function to each element of a slice