Skip to content

Latest commit

 

History

History
64 lines (49 loc) · 1.76 KB

File metadata and controls

64 lines (49 loc) · 1.76 KB

My queue adapter

A C++ template library implementing doubly-linked list (MyList), dynamic array (MyVector), and queue (MyQueue) with MyList or MyVector backends. Features iterators, copy/move semantics, initializer lists, and interoperability between containers.

Includes unit tests in main.cpp and CMake build support.

Features

  • MyList: Doubly-linked list with sentinel node, bidirectional iterators (mutable/const), push_back/front, pop_back/front, insert, find/rfind, clear.
  • MyVector: Dynamic array with capacity growth, random access, resize/reserve/grow, push_back/pop_back.
  • MyQueue: Adapter with push/pop/first/last/size/isempty; supports MyList (O(1) operations) or MyVector (circular buffer) backends.
  • STL-like operators: << for output, copy/move assignment/constructors.
  • Edge cases: Empty containers, move semantics, interoperability (e.g., List -> Queue -> Vector).

Build

Requires C++23.

mkdir build && cd build
cmake ..
make
./main

Runs all tests printing container states and operations.

Usage

MyList Example

MyList<int> list;
list.push_back(10); list.push_front(5);
std::cout << list.first() << " " << list.last() << std::endl;  // 5 10
auto it = list.find(5);
list.insert(999, it);

MyVector Example

MyVector<int> vec{1,2,3};
vec.push_back(4); vec.resize(5);

MyQueue Example

MyQueue<int, MyList<int>> q;
q.push(10); q.push(20);
std::cout << q.first() << " " << q.last() << std::endl;  // 10 20
q.pop();  // Removes 10

Full tests in src/main.cpp demonstrate all functionality.

Structure

├── include/
│ ├── mylist.h/inl
│ ├── myvector.h/inl
│ └── myqueue.h/inl
├── src/main.cpp
└── CMakeLists.txt