-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f62d70
commit 54b826c
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// Created by stefx on 7/7/24. | ||
// | ||
|
||
#include "vectorFunctions.hpp" | ||
|
||
std::vector<std::shared_ptr<int>> generate(int count) { | ||
std::vector<std::shared_ptr<int>> value; | ||
|
||
for (int i = 0; i < count; i++) { | ||
value.push_back(std::make_shared<int>(i)); | ||
} | ||
|
||
for (int it = 0; it < count; it++) { | ||
std::cout << "wynik to: " << *(value[it]); | ||
} | ||
return value; | ||
} | ||
|
||
void print(std::vector<std::shared_ptr<int>> printVector) { | ||
for (const auto& it : printVector) { | ||
std::cout << "Print: " << *it << std::endl; | ||
} | ||
} | ||
|
||
void add10(std::vector<std::shared_ptr<int>> addVector) { | ||
for (auto it : addVector) { | ||
if (it != nullptr) { | ||
*it += 10; | ||
} | ||
} | ||
} | ||
|
||
void sub10(int * const subVector) { | ||
if (subVector != nullptr) { | ||
*subVector -= 10; | ||
} | ||
} | ||
|
||
void sub10(std::vector<std::shared_ptr<int>> przeciazenieVector) { | ||
for (auto it : przeciazenieVector) { | ||
sub10(it.get()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// Created by stefx on 7/7/24. | ||
// | ||
|
||
#ifndef VECTOROFSHAREDPOINTERS_VECTORFUNCTIONS_HPP | ||
#define VECTOROFSHAREDPOINTERS_VECTORFUNCTIONS_HPP | ||
#include <iostream> | ||
#include <vector> | ||
#include <memory> | ||
|
||
std::vector<std::shared_ptr<int>> generate(int count); | ||
void print(std::vector<std::shared_ptr<int>> printVector); | ||
void add10(std::vector<std::shared_ptr<int>> addVector); | ||
void sub10(int * const subVector); | ||
void sub10(std::vector<std::shared_ptr<int>> przeciazenieVector); | ||
|
||
#endif //VECTOROFSHAREDPOINTERS_VECTORFUNCTIONS_HPP |