Skip to content

Commit 4846d81

Browse files
TylerMSFTTylerMSFT
and
TylerMSFT
authored
Iterator cleanup (#4554)
* updating * draft * add missing iterator functions * acrolinx and get iterator-functions.md in the build * fixed up iterator-functions.md * cleanup pass * acrolinx Co-authored-by: TylerMSFT <[email protected]>
1 parent e02c40d commit 4846d81

8 files changed

+959
-620
lines changed

docs/standard-library/iterator-functions.md

Lines changed: 523 additions & 225 deletions
Large diffs are not rendered by default.

docs/standard-library/iterator-operators.md

Lines changed: 369 additions & 327 deletions
Large diffs are not rendered by default.

docs/standard-library/iterator.md

Lines changed: 63 additions & 64 deletions
Large diffs are not rendered by default.
Loading
Loading
Loading
Loading

docs/standard-library/ranges.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
---
22
title: "<ranges>"
33
description: "Overview of the Standard Template Library (STL) ranges library"
4-
ms.date: 06/08/2022
4+
ms.date: 09/26/2022
55
f1_keywords: ["<ranges>"]
66
helpviewer_keywords: ["ranges"]
77
---
88

99
# `<ranges>`
1010

11-
At a high level, a range is something you can iterate over. A range abstracts iterators in a way that simplifies and amplifies your ability to use the Standard Template Library (STL).
11+
At a high level, a range is something you can iterate over. The containers, such as `vector`, `list`, and so on, in the C++ Standard Library are ranges. A range abstracts iterators in a way that simplifies and amplifies your ability to use the Standard Template Library (STL).
1212

13-
STL algorithms usually take iterators that point to the portion of the collection they should operate on. Consider how you sort a `vector` using `std::sort()`. You pass two iterators the mark the beginning and end of the `vector`. That provides flexibility, but passing the iterators to the algorithm is extra work since most of the time you just want to sort the whole thing.
13+
STL algorithms usually take iterators that point to the portion of the collection they should operate on. For example, consider how you sort a `vector` using `std::sort()`. You pass two iterators the mark the beginning and end of the `vector`. That provides flexibility, but passing the iterators to the algorithm is extra work since most of the time you just want to sort the whole thing.
1414

15-
With ranges, you can call `std::ranges::sort(myVector);` which is treated as if you had called `std::sort(myVector.begin(), myVector.end());` In range libraries, algorithms take ranges as parameters (although they can also take iterators, if you want). Examples of range algorithms available in `<algorithm>` include `copy`, `copy_n`, `copy_if`, `all_of`, `any_of`, and `none_of`, `find`, `find_if`, and `find_if_not`, `count` and `count_if`, `for_each` and `for_each_n`, `equal` and `mismatch`.
15+
With ranges, you can call `std::ranges::sort(myVector);` which is treated as if you had called `std::sort(myVector.begin(), myVector.end());` In range libraries, algorithms take ranges as parameters (although they can also take iterators, if you want). They can operate directly on collections. Some examples of range algorithms available in `<algorithm>` include `copy`, `copy_n`, `copy_if`, `all_of`, `any_of`, and `none_of`, `find`, `find_if`, and `find_if_not`, `count` and `count_if`, `for_each` and `for_each_n`, `equal` and `mismatch`.
1616

1717
But the benefits of ranges go further than this. Perhaps the most important benefit is that you can compose STL algorithms that operate on ranges much more easily.
1818

0 commit comments

Comments
 (0)