Skip to content

dhuss42/cpp08

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

cpp08

In this module, I worked with C++ templated containers, iterators, and standard algorithms.

ex00: Easy Find

I implemented a function template called easyfind that searched for a specific integer within a given container. It returned the first occurrence or handled the absence of the element appropriately using exceptions.

ex01: Span

I created a Span class to store a fixed number of integers and calculate the shortest and longest spans between them. For the shortest span, I made a copy of the object, sorted it, and then iterated over the sorted values, comparing neighboring elements to find the smallest difference. For the longest span, I used a similar approach but simply subtracted the first and last elements of the sorted container to determine the maximum distance.

ex02: Mutated Abomination

I extended the std::stack by creating a MutantStack class that allowed iteration over its elements. Beneath the std::stack container lies the deque container, which provides iterator support. I solved the exercise by inheriting from std::stack and exposing the underlying deque’s iterators.

About

Templated containers, iterators, algorithms

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published