CS Data Structures: Fixed Array

Photo by JOSE LARRAZOLO on Unsplash

Exordium

int foo [15];

Fixed Array Operations

Add ‘5’ to a fixed array that has a size of 15. All of the elements to the right of the array must be moved one position up in memory.
Deleting the number 5 from the middle of the array results in all of the elements to the right of the deleted element being moved one position to the left, freeing up a space in the array.

How to Build a Fixed Array

The Fundamental Properties

A Fixed Array in Swift
Add a custom subscript to Swift Fixed Array
Until an element is added to the Fixed Array, it will remain empty. In this implementation, there is no way to initialize the array and add elements in parallel

Adding Functionality to the Array

Add the insert method to the Fixed Array
Add some elements to the Fixed Array
Delete an element from a Fixed Array using Swift
Delete an element from a Fixed Array based on a given index
Remove all elements from a Fixed Array in Swift

Custom Subscript in a Fixed Array

Custom subscript of a Fixed Array in Swift

The Complete Fixed Array in Swift

Conclusion