Quickstart
Abstraction prevents code from repeating itself
Hello, My Old Friend
Generic was not a thing in Golang until v1.18 (Feb 2022). We're implementing different types of data structures which adopt generic feature. People can enjoy type checking and have better developer experience.
go get github.com/KafkaWannaFly/generic-collectionsOverall, we have ICollection, an interface that all structs have implemented. Plus, HashMap, a wrapper of built-in map with some convenient methods.
Working with Struct
This library works well with basic, primitive data-type. If you have any custom struct, which usually yes, you should implement IHashCoder and ILesser interfaces. They're used by library under the hood. E.g. Set would use IHashCoder to determine if 2 objects are the same. List would use ILesser when sorting items.
Example
Interface Definition
Can I Use Struct Without Implementing the Above Interfaces?
Yes, you can. The system will try to convert your struct into a string to compare.
What If My Object Can’t Be Converted?
GGWP ╮(╯_╰)╭
Last updated