An open API service indexing awesome lists of open source software.

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.

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.