Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You 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

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.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: