Arrays

About

The most fundamental idea of an Array is that it is a contiguous memory space.

This space must be informed in it's allocation, and you cannot grow it, only reallocate it to a new bigger or smaller Array.

Getting at specific index

Takes the width of the type (Bytes) and you multiply by the offset of the position you want.

circle-info

This take O(1)O(1), since you know the type width and the offset, you just multiply them.

Inserting at specific index (Not really inserting)

The content of the index is overwritten, since you cannot just grow the array size.

circle-info

Also O(1)O(1), since accessing at specific position is constant.

Deleting at specific index (Not really deleting)

Overwrite the content of the index to some specific null value. (Not necessarily null)

circle-info

Also O(1)O(1), since it is basically the same as inserting.

Last updated