I have just started to pick up go
, and I was going over the data structures. I am used to having a dynamic array like list
in python
or std::vector
in C++
, but I don't see anything similar in go
. The nice things about dynamic array is that it has O(1) time complexity to add a new element, and O(1) time complexity for indexing.
First I thought that slice
is it, but then I realized that when I used append function, the whole slice is being copied, and then therefore it is an O(N) operations as opposed to O(1) in dynamic array.
Then I came across list but this is a doubly linked list, which means that indexing is O(N), as opposed to O(1).
Am I missing the data structure I am looking for?