Hi all!
I was using growable vectors, gvector
, for some projects and I didn't find if the accessing time for this data structure is constant or not. Does anyone know about it?
For example, in the docs of list-ref
do specify that it takes time proportional to the position. But the same is not specified for gvector
.
Or am I missing something?
If it is not specified how can I submit a change to add that information?
Is the access time of a growable vector constant?
Yes.
(define (gvector-ref gv index [default none])
(unless (exact-nonnegative-integer? index)
(raise-type-error 'gvector-ref "exact nonnegative integer" index))
(if (< index (gvector-n gv))
(vector-ref (gvector-vec gv) index)
(cond [(eq? default none)
(check-index 'gvector-ref gv index #f)]
[(procedure? default) (default)]
[else default])))
From data/data-lib/data/gvector.rkt at master · racket/data · GitHub
2 Likes