From c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:08:27 +0200 Subject: add: graphs et rushs --- graphs/cpp/int_container/int_container.hh | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 graphs/cpp/int_container/int_container.hh (limited to 'graphs/cpp/int_container/int_container.hh') diff --git a/graphs/cpp/int_container/int_container.hh b/graphs/cpp/int_container/int_container.hh new file mode 100644 index 0000000..2df772a --- /dev/null +++ b/graphs/cpp/int_container/int_container.hh @@ -0,0 +1,45 @@ +#pragma once + +#include +#include +#include + +class MyIntContainer +{ +public: + MyIntContainer(size_t size); + + // Print the content of the container + void print() const; + + // Get the current number of elements inside the array + size_t get_len() const; + + // Add an element inside the array + bool add(int elem); + + // Get the last element inside the array and remove it + std::optional pop(); + + // Get the element at a given position + std::optional get(size_t position) const; + + // Get the index inside the array of a given element + std::optional find(int elem) const; + + // Sort the array + void sort(); + + // Checks if the array is sorted + bool is_sorted() const; + +private: + // Current size of the elems_ array + size_t current_size_; + + // Maximum size of the elems_ array + size_t max_size_; + + // Array containing the elements + std::unique_ptr elems_; +}; -- cgit v1.2.3