vector - sellout/data-structure-zoo GitHub Wiki
This is a mutable data structure, sometimes called an โarrayโ (which is too overloaded a term to use in this zoo) that can be used to implement a sequence or maybe a random-access list if you donโt care about some of the stack operations too much.
-
[[index]]
โ O(1) -
[[peek front]]
โ O(1) โ this is simply[[index]] 0 container
-
[[update!]]
โ O(1) -
[[chop front]]
โ O(n) -
[[chop front!]]
โ O(n) -
[[pop front!]]
โ O(n)
In a language like C where vectors (called arrays in that context) are provided as memory pointers, [[chop front]]
can be implemented in O(1). That should probably be a separate data structure, as Common Lisp provides something similar in its displaced arrays.