(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
Is count guaranteed to be constant time on vector?
If not, is there anyway to get the size of a vector in constant time?
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.
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 peek
to get its last element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With