Golang has both len(array)
and cap(array)
. The former returns the length of the array/slice (that being the amount of elements the array has); as I understand it, that function is O(1); which makes it immediate
cap(array)
returns the capacity of the underlying array. However, is that operation O(1)? One would think that the capacity of an array is a value that the array has, and thus could see in O(1) time, but I can't tell for certain