
GoDS (Go Data Structures) (golang) - japanac
https://github.com/emirpasic/gods
======
andrewfromx
Why use a hashmap vs the built in golang map?

~~~
japanac
these two are the same, since one uses the other. i agree with you as the
author of gods, that if it fits your problem, then use golang map by all
means. however, if you use golang map and realize that your problem needs the
keys to be ordered, for which the ordering is randomized in golang, then
having used hashmap in the first place would allow you to easily switch to
treemap without any changes to your code, since both implement the same
interface. implementing a treemap, consequently also a red-black tree, is
something i wouldn't do again. keeping the keys sorted in another golang's
native structure is also cumbersome and will lead to consistency issues and
unnecessary memory usage. in short: use the data structure that fits your
problem, golang native, gods or other. gods attempts to provide well-defined
shareable structure for various data structures as to eliminate the need to
write that boilerplate logic all over.

~~~
japanac
consider an even simpler example of wanting an array that contains no
duplicates and is sorted. i can write the logic for that in 5 minutes, but it
will be bother memory and cpu inefficient. i would spend another 20 minutes
optimizing that logic. by the time i'm done with that, i've forgotten why i
needed that in the first place. importing gods' treeset would have been a lot
easier, since it solves that problem.

