This project is a lightweight, template‑based vector (dynamic array) library implemented in C++. It was developed both as a learning exercise in generic programming and as a potential alternative to the standard library for environments with tight resource constraints.
- About the Project
- Features
- Technologies Used
- Installation & Usage
- API Reference
- Project Structure
- Development Process
- Contributing
- Contact
- License
The library provides a generic myVector<T> class that supports common vector operations such as adding, removing, sorting, and element access. It uses manual dynamic memory management (raw pointers) to demonstrate how such containers work under the hood, making it especially useful for students and embedded developers.
- Developer: Haluk Can SARIÖZ
- Type: C++ Template Library
- Purpose: Practice template programming and dynamic memory management
- Generic Design: The
myVector<T>class works with any data type (int,char,double, etc.). - Basic Vector Operations: Add, remove, get, sort, and erase elements.
- Lightweight: No dependencies beyond the standard C library, making it suitable for constrained environments.
- Built‑in Examples: The
main()function demonstrates usage with bothcharandinttypes.
- C++ – Core language.
- Template Metaprogramming – Type‑independent class and function design.
- GCC / G++ – Compiler.
- VS Code / Dev-C++ – Editors.
git clone https://github.com/halukcansarioz/Vector-Methods.gitcd Vector-MethodsLinux / macOS:
g++ Vector.cpp -o vector_appWindows (MinGW / GCC required):
g++ Vector.cpp -o vector_app.exeNote: Since templates are used, the implementation is included in
Vector.cpp(which also contains the demonstrationmain()). If you separate the header and implementation in the future, you will need to include the.cppfile as well.
# Linux / macOS
./vector_app
# Windows
vector_app.exeThe program will ask for the vector size and then prompt you to enter character and integer values to test the operations.
The myVector<T> class provides the following public methods:
| Method | Description |
|---|---|
myVector(int num) |
Constructs a vector with a specified initial capacity. |
~myVector() |
Destructor – releases allocated memory. |
int size() |
Returns the number of elements currently stored. |
void add(T s) |
Adds a new element to the end of the vector. Warns if capacity is exceeded. |
T getAt(int index) |
Returns the element at the given index. |
void getElement(int index) |
Prints the element at the given index to the console. |
void remove(T s) |
Removes the first occurrence of the specified value. |
void erase(int index) |
Removes the element at the specified index. |
void sort() |
Sorts the vector in ascending order using Bubble Sort. |
Vector-Methods/
├── Vector.h # Template class header (interface)
├── Vector.cpp # Template method implementations + example main()
├── .gitattributes # Git configuration
└── README.md # Project documentation
Fork the project to extend the library with additional features.
git checkout -b feature/new-methodgit push origin feature/new-method- Fork this repository.
- Create a Branch (
git checkout -b feature/NewMethod). - Add a new method or improve existing code.
- Commit your changes (
git commit -m 'Add: reverse() method'). - Push your branch (
git push origin feature/NewMethod). - Open a Pull Request.
💡 Ideas for new methods:
reverse(),contains(),clear(),resize(),operator[]overload.
Haluk Can Sarıöz
- GitHub: @halukcansarioz
- Email: halukcansarioz19@gmail.com
- LinkedIn: Haluk Can Sarıöz
Project Link: https://github.com/halukcansarioz/Vector-Methods
This project is licensed under the MIT License.