From b32f5a56b0cbce38d72403e49b6c9993f5b70a19 Mon Sep 17 00:00:00 2001 From: Pulsarnixx Date: Mon, 31 Aug 2026 12:15:54 +0200 Subject: [PATCH 1/6] Created vectorFunctions.* files. --- homework/vector-of-shared-ptrs/vectorFunctions.cpp | 0 homework/vector-of-shared-ptrs/vectorFunctions.hpp | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 homework/vector-of-shared-ptrs/vectorFunctions.cpp create mode 100644 homework/vector-of-shared-ptrs/vectorFunctions.hpp diff --git a/homework/vector-of-shared-ptrs/vectorFunctions.cpp b/homework/vector-of-shared-ptrs/vectorFunctions.cpp new file mode 100644 index 00000000..e69de29b diff --git a/homework/vector-of-shared-ptrs/vectorFunctions.hpp b/homework/vector-of-shared-ptrs/vectorFunctions.hpp new file mode 100644 index 00000000..e69de29b From 569dcbc34c5aa4a4a02b661447b93f6676fcbdba Mon Sep 17 00:00:00 2001 From: Pulsarnixx Date: Mon, 31 Aug 2026 12:37:01 +0200 Subject: [PATCH 2/6] Generate done. --- .../vector-of-shared-ptrs/vectorFunctions.cpp | 27 +++++++++++++++++++ .../vector-of-shared-ptrs/vectorFunctions.hpp | 14 ++++++++++ 2 files changed, 41 insertions(+) diff --git a/homework/vector-of-shared-ptrs/vectorFunctions.cpp b/homework/vector-of-shared-ptrs/vectorFunctions.cpp index e69de29b..af781198 100644 --- a/homework/vector-of-shared-ptrs/vectorFunctions.cpp +++ b/homework/vector-of-shared-ptrs/vectorFunctions.cpp @@ -0,0 +1,27 @@ +#include "vectorFunctions.hpp" + +std::vector> generate(int count) { + std::vector> result; + result.reserve(count); + + for (size_t i = 0; i < count; ++i) { + result.push_back(std::make_shared(i)); + } + + return result; +} + +void print(const std::vector>& vec) { + // TODO +} +void add10(std::vector>& vec) { + // TODO +} + +void sub10(int* const ptr) { + // TODO +} + +void sub10(std::vector>& vec) { + // TODO +} diff --git a/homework/vector-of-shared-ptrs/vectorFunctions.hpp b/homework/vector-of-shared-ptrs/vectorFunctions.hpp index e69de29b..2e78f17b 100644 --- a/homework/vector-of-shared-ptrs/vectorFunctions.hpp +++ b/homework/vector-of-shared-ptrs/vectorFunctions.hpp @@ -0,0 +1,14 @@ +#ifndef VECTOR_FUNCTIONS_H +#define VECTOR_FUNCTIONS_H + +#include +#include + +std::vector> generate(int count); +void print(const std::vector>& vec); +void add10(std::vector>& vec); + +void sub10(int* const ptr); +void sub10(std::vector>& vec); + +#endif From 6b4bf510344307e5fcd2cd75e29f69c8a324ea79 Mon Sep 17 00:00:00 2001 From: Pulsarnixx Date: Mon, 31 Aug 2026 12:41:53 +0200 Subject: [PATCH 3/6] Print done. --- homework/vector-of-shared-ptrs/vectorFunctions.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/homework/vector-of-shared-ptrs/vectorFunctions.cpp b/homework/vector-of-shared-ptrs/vectorFunctions.cpp index af781198..9dbba8da 100644 --- a/homework/vector-of-shared-ptrs/vectorFunctions.cpp +++ b/homework/vector-of-shared-ptrs/vectorFunctions.cpp @@ -1,5 +1,7 @@ #include "vectorFunctions.hpp" +#include + std::vector> generate(int count) { std::vector> result; result.reserve(count); @@ -12,7 +14,11 @@ std::vector> generate(int count) { } void print(const std::vector>& vec) { - // TODO + for (const auto& ptr : vec) { + std::cout << *ptr << ' '; + } + + std::cout << '\n'; } void add10(std::vector>& vec) { // TODO From e8ff2e76a1beb25bb40ea3a6ee2f16a35a24eb18 Mon Sep 17 00:00:00 2001 From: Pulsarnixx Date: Mon, 31 Aug 2026 12:43:57 +0200 Subject: [PATCH 4/6] Add10 done. --- homework/vector-of-shared-ptrs/vectorFunctions.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homework/vector-of-shared-ptrs/vectorFunctions.cpp b/homework/vector-of-shared-ptrs/vectorFunctions.cpp index 9dbba8da..f7973809 100644 --- a/homework/vector-of-shared-ptrs/vectorFunctions.cpp +++ b/homework/vector-of-shared-ptrs/vectorFunctions.cpp @@ -21,7 +21,9 @@ void print(const std::vector>& vec) { std::cout << '\n'; } void add10(std::vector>& vec) { - // TODO + for (const auto& ptr : vec) { + *ptr += 10; + } } void sub10(int* const ptr) { From 9eb13c419c981a7d7921e6b005d8f66afea10645 Mon Sep 17 00:00:00 2001 From: Pulsarnixx Date: Mon, 31 Aug 2026 12:45:31 +0200 Subject: [PATCH 5/6] Add10 done v2. --- homework/vector-of-shared-ptrs/vectorFunctions.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homework/vector-of-shared-ptrs/vectorFunctions.cpp b/homework/vector-of-shared-ptrs/vectorFunctions.cpp index f7973809..41890fec 100644 --- a/homework/vector-of-shared-ptrs/vectorFunctions.cpp +++ b/homework/vector-of-shared-ptrs/vectorFunctions.cpp @@ -22,7 +22,9 @@ void print(const std::vector>& vec) { } void add10(std::vector>& vec) { for (const auto& ptr : vec) { - *ptr += 10; + if (ptr) { + *ptr += 10; + } } } From 4d6d0a8b10c54362b746bd9cd821b37af8a1035d Mon Sep 17 00:00:00 2001 From: Pulsarnixx Date: Mon, 31 Aug 2026 12:49:22 +0200 Subject: [PATCH 6/6] Sub10 done. --- homework/vector-of-shared-ptrs/vectorFunctions.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/homework/vector-of-shared-ptrs/vectorFunctions.cpp b/homework/vector-of-shared-ptrs/vectorFunctions.cpp index 41890fec..8263ac82 100644 --- a/homework/vector-of-shared-ptrs/vectorFunctions.cpp +++ b/homework/vector-of-shared-ptrs/vectorFunctions.cpp @@ -29,9 +29,13 @@ void add10(std::vector>& vec) { } void sub10(int* const ptr) { - // TODO + if (ptr) { + *ptr -= 10; + } } void sub10(std::vector>& vec) { - // TODO + for (const auto& ptr : vec) { + sub10(ptr.get()); + } }