Skip to content

Golang Generics Support

Latest
Compare
Choose a tag to compare
@jucardi jucardi released this 10 Nov 03:33
· 5 commits to master since this release
  • Refactored this library and all implementation to use Golang Generics.
  • Added base implementations of collections and iterators with abstract members so they can be used as base for new implementations of these types.
  • Existing interfaces have been revisited and redesigned to go more accordingly to what they are meant to represent.
  • ICollection[T comparable] is now more generic and have no predifined functions related to indexes.
  • Added new interface type IList[T comparable] which implements ICollection[T comparable] with the addition to functions related to indexes in a list, such as Index, At and RemoveAt
  • Added new interface type ISet[T comparable] which implements ICollection[T comparable] and defines collections with only unique values.
  • Added default implementation of ISet[T].
  • Added new interface type Map[K,V comparable] which implements ICollection[KeyValuePair[K,V]] and has additional functions related to maps.
  • Added default implementation of Map[K,V comparable] which also uses a mutex to be thread safe.
  • Moved the function Map out of IStream[T] since Golang Generics does not support additional generic parameters to interface functions.
  • The Map function is now a static function in the 'streams' package and has been redesigned to Map[From,To comparable](source any, ConvertFunc[From,To]) IList[To] where the source can be []From or IIterator[From]
  • Added mapping function MapNonComparable[From, To any](source any, ConvertFunc[From, To]) []To for simple cases where the use of streams is not required for a mapping and allowing non-comparable types to be used
  • Added mapping function MapToPtr[T any]() []*T to easily convert arrays of non-comparable structures to arrays of pointers to that structure (T to *T) which allows the resulting array to be used in streams