For a non-OOP language like google Go, is it idiomatic to go about implementing new container types using datatypes like arrays or lists so as to implement convenient functionality like contains method which is absent from all in built container types?
Tell me more
×
Programmers Stack Exchange is a question and answer site for
professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.
|
|
|||||||
|
|
The container package currently contains built-in objects for heaps, doubly linked lists, and circular lists. The source code for the container/list package also gives the idiomatic way to iterate over lists. With datatypes so easy to define, I don't think there is any problem in implementing new containers on your own. I would also imagine that as Go matures, it will add additional built-in data structures. A channel is essentially a FIFO queue; see this source for help on making your own types thread-safe. |
||||
|
|