From 497cef93184b86cf0b30209b7574da18738b10b9 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 5 Feb 2020 21:58:21 +0100 Subject: [PATCH 1/3] Added contains method to set I used Coliru online compiler instead of ideone because the latter does not support C++2a yet (contains is a C++20 feature), I hope it is not a problem! --- set/README.md | 2 +- set/contains.md | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 set/contains.md diff --git a/set/README.md b/set/README.md index 5f679c4f..64e3ffb1 100644 --- a/set/README.md +++ b/set/README.md @@ -3,6 +3,7 @@ :heavy_check_mark: [cbegin](cbegin.md) :heavy_check_mark: [cend](cend.md) :heavy_check_mark: [clear](clear.md) +:heavy_check_mark: [contains](contains.md) :heavy_check_mark: [count](count.md) :heavy_check_mark: [emplace](emplace.md) :heavy_check_mark: [emplace_hint](emplace_hint.md) @@ -19,7 +20,6 @@ :heavy_check_mark: [size](size.md) :heavy_check_mark: [swap](swap.md) :heavy_check_mark: [upper_bound](upper_bound.md) -:x: contains :x: crbegin :x: crend :x: extract diff --git a/set/contains.md b/set/contains.md new file mode 100644 index 00000000..24504dc0 --- /dev/null +++ b/set/contains.md @@ -0,0 +1,36 @@ +# contains + +**Description :** + This method is used to know if a value exists in a set. If the given value is an element of set, the method returns true, otherwise it returns false. + +**Example :** +```cpp +//Run code to demonstrate use of set.contains() +#include +#include + +int main() { + + // Create a set with different integer values + std::set mySet = {1, 2, 3, 4, -5}; + + // Check if the set contains the value 1 + if (mySet.contains(1)) { + std::cout << "1 exists in mySet" << std::endl; + } else { + std::cout << "1 does not exist in mySet" << std::endl; + } + + // Check if the set contains the value 12 + if (mySet.contains(12)) { + std::cout << "12 exists in mySet" << std::endl; + } else { + std::cout << "12 does not exist in mySet" << std::endl; + } + + return 0; +} + +``` + +**[Run Code](https://coliru.stacked-crooked.com/a/367f7b4450afe750)** From d1354bce267bef381f1e3f2459eb96cc151d8ce4 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 5 Feb 2020 22:20:22 +0100 Subject: [PATCH 2/3] Revert "Added contains method to set" This reverts commit 497cef93184b86cf0b30209b7574da18738b10b9. --- set/README.md | 2 +- set/contains.md | 36 ------------------------------------ 2 files changed, 1 insertion(+), 37 deletions(-) delete mode 100644 set/contains.md diff --git a/set/README.md b/set/README.md index 64e3ffb1..5f679c4f 100644 --- a/set/README.md +++ b/set/README.md @@ -3,7 +3,6 @@ :heavy_check_mark: [cbegin](cbegin.md) :heavy_check_mark: [cend](cend.md) :heavy_check_mark: [clear](clear.md) -:heavy_check_mark: [contains](contains.md) :heavy_check_mark: [count](count.md) :heavy_check_mark: [emplace](emplace.md) :heavy_check_mark: [emplace_hint](emplace_hint.md) @@ -20,6 +19,7 @@ :heavy_check_mark: [size](size.md) :heavy_check_mark: [swap](swap.md) :heavy_check_mark: [upper_bound](upper_bound.md) +:x: contains :x: crbegin :x: crend :x: extract diff --git a/set/contains.md b/set/contains.md deleted file mode 100644 index 24504dc0..00000000 --- a/set/contains.md +++ /dev/null @@ -1,36 +0,0 @@ -# contains - -**Description :** - This method is used to know if a value exists in a set. If the given value is an element of set, the method returns true, otherwise it returns false. - -**Example :** -```cpp -//Run code to demonstrate use of set.contains() -#include -#include - -int main() { - - // Create a set with different integer values - std::set mySet = {1, 2, 3, 4, -5}; - - // Check if the set contains the value 1 - if (mySet.contains(1)) { - std::cout << "1 exists in mySet" << std::endl; - } else { - std::cout << "1 does not exist in mySet" << std::endl; - } - - // Check if the set contains the value 12 - if (mySet.contains(12)) { - std::cout << "12 exists in mySet" << std::endl; - } else { - std::cout << "12 does not exist in mySet" << std::endl; - } - - return 0; -} - -``` - -**[Run Code](https://coliru.stacked-crooked.com/a/367f7b4450afe750)** From b6a77778eefae8455ddf6daadcdd908bd790c55f Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 5 Feb 2020 22:22:46 +0100 Subject: [PATCH 3/3] Added contains method to set I used Coliru online compiler instead of ideone because the latter does not support C++2a yet (contains is a C++20 feature), I hope it is not a problem! I reverted my first commit because I edited README.md even though I was not supposed to :sweat_smile: --- set/contains.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 set/contains.md diff --git a/set/contains.md b/set/contains.md new file mode 100644 index 00000000..24504dc0 --- /dev/null +++ b/set/contains.md @@ -0,0 +1,36 @@ +# contains + +**Description :** + This method is used to know if a value exists in a set. If the given value is an element of set, the method returns true, otherwise it returns false. + +**Example :** +```cpp +//Run code to demonstrate use of set.contains() +#include +#include + +int main() { + + // Create a set with different integer values + std::set mySet = {1, 2, 3, 4, -5}; + + // Check if the set contains the value 1 + if (mySet.contains(1)) { + std::cout << "1 exists in mySet" << std::endl; + } else { + std::cout << "1 does not exist in mySet" << std::endl; + } + + // Check if the set contains the value 12 + if (mySet.contains(12)) { + std::cout << "12 exists in mySet" << std::endl; + } else { + std::cout << "12 does not exist in mySet" << std::endl; + } + + return 0; +} + +``` + +**[Run Code](https://coliru.stacked-crooked.com/a/367f7b4450afe750)**