Fandom

Programmer's Wiki

Dynamic array

406pages on
this wiki
Add New Page
Talk0 Share

A dynamic array is a resizable array data structure that can be dynamically resized as items are added to or removed from it.

As with static arrays, it allows O(1) random access. An advantage is that it also allows addition at the end, until it reaches a certain capacity, in which case it reassigns a new capacity and reallocates itself.

ImplementationsEdit

C++ Edit

Dynamic arrays are implemented using vectors. In C++, vectors are part of the STL. They can be accesed by including vector.h, and are in the 'std' namespace;

#include <vector>

int main(void)
{
  std::vector<int> myVec;
  return 0;
}
16px-Pencil

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.