Context
(doc count)
-------------------------
clojure.core/count
([coll])
Returns the number of items in the collection. (count nil) returns
0. Also works on strings, arrays, and Java Collections and Maps
Question
Is count guaranteed to be constant time on vector?
If not, is there anyway to get the size of a vector in constant time?
More Context
I actually want to get the list element of a vector, which I can do in O(1) with nth, assuming I know the vector size.
EDIT:
I forgot to mention this. I need this to work on a transient vector.
Yes, count is always fast on a vector. But you can just call
peekto get its last element.