https://github.com/liavbarsheshet/initialized-array
Implementation of a generic Initialized Array.
https://github.com/liavbarsheshet/initialized-array
array cpp init initalized-array initarray initialize initialized
Last synced: 5 months ago
JSON representation
Implementation of a generic Initialized Array.
- Host: GitHub
- URL: https://github.com/liavbarsheshet/initialized-array
- Owner: liavbarsheshet
- License: mit
- Created: 2022-09-25T12:03:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-09-25T12:07:21.000Z (over 3 years ago)
- Last Synced: 2025-06-22T00:39:01.692Z (8 months ago)
- Topics: array, cpp, init, initalized-array, initarray, initialize, initialized
- Language: C++
- Homepage:
- Size: 1.95 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# C++ Initialized Array
Implementation of a generic Initialized Array.
---
## Declaration
Supports >= c++11:
```c++
#include "initialized-array.hpp"
auto initialized_array = InitArr::InitializedArray();
```
## Template
```c++
/**
* Class: Represents an initialized array.
* @tparam Value - The type/class of the value.
* @tparam Number - Class/Primitive number type for index representation.
*/
template
class InitArr::InitializedArray{...}
```
## Methods
Implementation of a Generic Initialized Array.
```cpp
/**
* Constructor: Creates an initialized array.
* @note Worst-Time Complexity: O(1).
* @note Worst-Space Complexity: O(3n).
* @param length - The length of the array.
* @param def - The default value which all values will be initialized to.
*/
InitializedArray(Number length, Value def);
/**
* Copy Constructor: Creates an initialized array from an existing one.
* @note Worst-Time Complexity: O(top) <= O(n).
* @note Worst-Space Complexity: O(3n).
* @param arr - The array reference.
*/
InitializedArray(const InitializedArray &arr);
/**
* Destructor: Deallocates the entire array.
* @note Without responsibility of the content(items).
* @note Worst-Time Complexity: O(1).
*/
~InitializedArray();
/**
* Gets the element at a specific index.
* @note Worst-Time Complexity: O(1).
* @param index - Specific index of an element.
* @return {Value} Returns the element at specific index.
*/
Value Get(const Number &index) const;
/**
* Sets the element at a specific index.
* @note Worst-Time Complexity: O(1).
* @param index - Specific index of an element.
* @param value - Specific value.
*/
void Set(const Number &index, Value value);
/**
* Gets the default value.
* @note Worst-Time Complexity: O(1).
* @return {Value} Returns the default value.
*/
Value Default() const;
/**
* Gets the length of the array.
* @note Worst-Time Complexity: O(1).
* @return {Number} Returns the length of the array.
*/
Number Length() const;
/**
* Gets the element at a specific index.
* @note Worst-Time Complexity: O(1).
* @param index - Specific index of an element.
* @return {Value} Returns the element at specific index.
*/
Value operator[](const Number &index);
```
## Author
[Liav Barsheshet, LBDevelopments](https://github.com/liavbarsheshet)
## License
[MIT](LICENSE)