# Is the access time of a growable vector constant?

**URL:** <https://racket.discourse.group/t/is-the-access-time-of-a-growable-vector-constant/2690>\
**Category:** General\
**Tags:** question\
**Created:** [January 30, 2024, 6:03am UTC](https://racket.discourse.group/t/is-the-access-time-of-a-growable-vector-constant/2690 "2024-01-30T06:03:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![leoflotor](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/leoflotor/32/1606_2.png) [@leoflotor](https://racket.discourse.group/u/leoflotor)\
**Post date:** [January 30, 2024, 6:03am UTC](https://racket.discourse.group/t/is-the-access-time-of-a-growable-vector-constant/2690/1 "2024-01-30T06:03:49Z")

</div>

Hi all!

I was using growable vectors, [`gvector`](https://docs.racket-lang.org/data/gvector.html), 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`](https://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list-ref%29%29) 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?

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [January 30, 2024, 11:00am UTC](https://racket.discourse.group/t/is-the-access-time-of-a-growable-vector-constant/2690/2 "2024-01-30T11:00:00Z")

</div>

> Is the access time of a growable vector constant?  
> Yes.

```scheme
(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](https://github.com/racket/data/blob/master/data-lib/data/gvector.rkt)
