Skip to content

Commit

Permalink
Implement new function findByValue()
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Jun 24, 2020
1 parent be84370 commit d314388
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ bool checkNumeric(std::string *firstNum, std::string *secondNum);
template<typename T, typename Key>
bool key_exists(const T &container, const Key &key);

template<typename Key, typename Value>
bool findByValue(std::map<Key, Value> mapOfElemen, Value value);

void printHelp();

int main(int argc, char **argv) {
Expand Down Expand Up @@ -283,6 +286,18 @@ bool key_exists(const T &container, const Key &key) {
return container.find(key) != end(container);
}

template<typename Key, typename Value>
bool findByValue(std::map<Key, Value> mapOfElemen, Value value) {
auto iterator = mapOfElemen.begin();
while (iterator != mapOfElemen.end()) {
if (iterator->second == value) {
return true;
}
}

return false;
}

void printHelp() {
cout << "Usage: Program PATH [OPTION] < [FILE] ...\n"
" or: Program PATH [OPTION] file name\n"
Expand Down

0 comments on commit d314388

Please sign in to comment.