https://github.com/taharachedi/custom_dynamic_array_library-cpp
A C++ template-based dynamic array implementation offering essential operations such as insertion, deletion, resizing, searching, and reversal.
https://github.com/taharachedi/custom_dynamic_array_library-cpp
datastructures-algorithms dynamic-array
Last synced: 8 months ago
JSON representation
A C++ template-based dynamic array implementation offering essential operations such as insertion, deletion, resizing, searching, and reversal.
- Host: GitHub
- URL: https://github.com/taharachedi/custom_dynamic_array_library-cpp
- Owner: taharachedi
- Created: 2025-03-07T11:35:21.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-03-07T11:57:26.000Z (8 months ago)
- Last Synced: 2025-03-07T12:29:04.330Z (8 months ago)
- Topics: datastructures-algorithms, dynamic-array
- Language: C++
- Homepage:
- Size: 0 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# πDynamic Array Implementation (clsDynamicArray)β‘
> **A C++ template-based dynamic array implementation with powerful functionalities for managing elements efficiently. π**
---
## π Project Overview
The `clsDynamicArray` class is a **generic dynamic array** implementation in C++ that supports **resizing**, **modifications**, and **element manipulations**. It provides a flexible way to manage collections of data with dynamic memory allocation, ensuring optimal performance and usability.
### πΉ Core Functionalities:
- **Insert** elements at any position β
- **Delete** elements efficiently β
- **Resize** dynamically to manage memory β»οΈ
- **Reverse** the entire array order π
- **Find & Modify** elements easily π
- **Clear** the array in one call β¨
This implementation leverages **C++ templates**, making it compatible with any data type.
---
## β¨ Features
### πΉ Basic Operations
- **`SetItem(Index, Value)`**: Updates the element at a specific index.
- **`GetItem(Index)`**: Retrieves the element at a given index.
- **`Size()`**: Returns the total number of elements in the array.
- **`IsEmpty()`**: Checks if the array is empty.
- **`PrintList()`**: Displays all elements in the array.
### πΉ Advanced Functionalities
- **`Resize(New_Size)`**: Adjusts the size of the array dynamically.
- **`Reverse()`**: Reverses the order of elements.
- **`Clear()`**: Removes all elements and frees memory.
- **`Find(Value)`**: Returns the index of the first occurrence of a value (-1 if not found).
- **`DeleteItem(Value)`**: Deletes the first occurrence of a given value.
- **`DeleteItemAt(Index)`**: Deletes the element at a specific index.
- **`DeleteFirstItem()`**: Removes the first element.
- **`DeleteLastItem()`**: Removes the last element.
- **`InsertAt(Index, Value)`**: Inserts an element at a specified position.
- **`InsertAtBeginning(Value)`**: Inserts an element at the start.
- **`InsertAtEnd(Value)`**: Inserts an element at the end.
- **`InsertBefore(Index, Value)`**: Inserts an element before a given index.
- **`InsertAfter(Index, Value)`**: Inserts an element after a given index.
---
## π How It Works
### πΉ Insertion & Deletion
- Use `InsertAt(Index, Value)` to place an element at a specific position.
- `DeleteItemAt(Index)` removes an element from a given index.
- `DeleteFirstItem()` and `DeleteLastItem()` handle edge cases.
### πΉ Resizing & Memory Management
- `Resize(New_Size)` adjusts the capacity dynamically, ensuring optimal usage.
- `Clear()` safely deletes all elements to prevent memory leaks.
### πΉ Searching & Modifications
- `Find(Value)` locates elements efficiently.
- `SetItem(Index, Value)` allows modifying elements dynamically.
---
## π Potential Enhancements
- π’ **Iterator Support**: Enabling STL-like traversal.
- β **Performance Optimization**: Enhancing efficiency for large datasets.
- πΎ **Persistent Storage**: Implementing file-based data storage.
- β **Thread Safety**: Supporting concurrent operations.
---
## βοΈ Technologies Used
- **Language**: C++
- **Templates**: Supports multiple data types.
- **Dynamic Memory Allocation**: Utilizes heap memory efficiently.
---
## π― Learning Outcomes
This project demonstrates:
- β
**Dynamic memory management with pointers**
- β
**Efficient array operations (insert, delete, find, modify)**
- β
**Generic programming using C++ templates**
---
## π License
This project is **open-source**. Feel free to modify and enhance it! π
---
## π€ Contributing
Contributions are welcome! If you have ideas for improvements, submit a Pull Request.
---
## π Ready to Explore?
### π How to Run
1. **Download** the repository.
2. **Include** `clsDynamicArray.h` in your project.
3. **Compile & Run** your C++ program with a standard compiler (e.g., `g++ main.cpp -o output`).
4. **Test** various array operations.