3 ms·
The number of times you'll wish you had a generic red-black tree or linked list in your life: many, many times. The number of times you'll need a generic map o
by EvenThisAcronym 12y ago
The number of times you'll wish you had a generic red-black tree or linked list in your life: many, many times.
The number of times you'll need a generic map or fold algorithm to operate on those structures: many, many times.
- grey-area 12y agoYou could easily define an interface and write your red black tree once for all types, you'd just have to wrap basic types like int to conform if you want to add them (most often this sort of list is of a custom data type though). e.g. https://github.com/petar/gollrb https://github.com/petar/gollrb So if you need a data structure like this, you can do it without much trouble without generics. Perhaps you don't feel that solution is as clean, but it's certainly pretty easy to do. NB that golang has not ruled out generics, it's just not something they felt compelled to put in initially, and not many people who use the language miss them.