forked from Bhupesh-V/30-seconds-of-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Aokison/30-seconds-of-cpp
- Loading branch information
Showing
1 changed file
with
28 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,28 @@ | ||
# crend | ||
|
||
**Description :** | ||
This method is used to return a const_reverse_iterator pointing to the position preceding the first element of the container. This is useful | ||
when wanting a read-only iterator to iterate a container in reverse order. | ||
|
||
**Example :** | ||
```cpp | ||
//Run Code To Demonstrate use of set.crend() | ||
#include<iostream> | ||
#include<set> | ||
|
||
int main() { | ||
// Create a set object holding integers | ||
std::set<int> myset{ 2, 4, 3, 5, 1 }; | ||
|
||
// Iterate through the const_reverse_iterator | ||
std::cout << "myset reversed:"; | ||
for (auto r_it = myset.crbegin(); r_it != myset.crend(); ++r_it){ | ||
std::cout << ' ' << *r_it; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
``` | ||
|
||
**[Run Code](https://rextester.com/YAWBA53642)** |