You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cppcx/collections-c-cx.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ The Windows Runtime defines the interfaces for collections and related types, an
20
20
- Iterators are defined in the [`Platform::Collections` Namespace](platform-collections-namespace.md). These iterators satisfy the requirements for STL iterators and enable the use of [`std::find`](../standard-library/algorithm-functions.md#find), [`std::count_if`](../standard-library/algorithm-functions.md#count_if), and other STL algorithms on any [`Windows::Foundation::Collections`](/uwp/api/windows.foundation.collections) interface type or [`Platform::Collections`](platform-collections-namespace.md) concrete type. For example, this means that you can iterate a collection in a Windows Runtime component that's created in C# and apply an STL algorithm to it.
21
21
22
22
> [!IMPORTANT]
23
-
> Proxy iterators `VectorIterator` and `VectorViewIterator` utilize proxy objects `VectoryProxy<T>` and `ArrowProxy<T>` to enable usage with STL containers. For more information, see [VectorProxy elements](#vectorproxy-elements) later in this article.
23
+
> Proxy iterators `VectorIterator` and `VectorViewIterator` utilize proxy objects `VectorProxy<T>` and `ArrowProxy<T>` to enable usage with STL containers. For more information, see [VectorProxy elements](#vectorproxy-elements) later in this article.
24
24
25
25
- The C++/CX collection types support the same thread safety guarantees that STL containers support.
26
26
@@ -53,7 +53,7 @@ Any element to be stored in a [`Platform::Collections::Vector`](platform-collect
53
53
54
54
[`Platform::Collections::VectorIterator`](platform-collections-vectoriterator-class.md) and [`Platform::Collections::VectorViewIterator`](platform-collections-vectorviewiterator-class.md) enable the use of `range for` loops and algorithms like [`std::sort`](../standard-library/algorithm-functions.md#sort) with an [`IVector<T>`](/uwp/api/windows.foundation.collections.ivector-1) container. But `IVector` elements cannot be accessed through C++ pointer dereference; they can be accessed only through [`GetAt`](/uwp/api/windows.foundation.collections.ivector-1.getat) and [`SetAt`](/uwp/api/windows.foundation.collections.ivector-1.setat) methods. Therefore, these iterators use the proxy classes `Platform::Details::VectorProxy<T>` and `Platform::Details::ArrowProxy<T>` to provide access to the individual elements through **`*`**, **`->`**, and **`[]`** operators, as required by the Standard Library. Strictly speaking, given an `IVector<Person^> vec`, the type of `*begin(vec)` is `VectorProxy<Person^>`. However, the proxy object is almost always transparent to your code. These proxy objects are not documented because they are only for internal use by the iterators, but it is useful to know how the mechanism works.
55
55
56
-
When you use a range-based **`for`** loop over `IVector` containers, use `auto&&` to enable the iterator variable to bind correctly to the `VectorProxy` elements. If you use `auto&`, compiler warning [C4239](../error-messages/compiler-warnings/compiler-warning-level-4-c4239.md) is raised and `VectoryProxy` is mentioned in the warning text.
56
+
When you use a range-based **`for`** loop over `IVector` containers, use `auto&&` to enable the iterator variable to bind correctly to the `VectorProxy` elements. If you use `auto&`, compiler warning [C4239](../error-messages/compiler-warnings/compiler-warning-level-4-c4239.md) is raised and `VectorProxy` is mentioned in the warning text.
57
57
58
58
The following illustration shows a `range for` loop over an `IVector<Person^>`. Notice that execution is stopped on the breakpoint on line 64. The **QuickWatch** window shows that the iterator variable `p` is in fact a `VectorProxy<Person^>` that has `m_v` and `m_i` member variables. However, when you call `GetType` on this variable, it returns the identical type to the `Person` instance `p2`. The takeaway is that although `VectorProxy` and `ArrowProxy` might appear in **QuickWatch**, the debugger certain compiler errors, or other places, you typically don't have to explicitly code for them.
59
59
@@ -92,7 +92,7 @@ Elements in a [`Platform::Collections::Map`](platform-collections-map-class.md)
92
92
93
93
Collections fall into four categories: modifiable versions and read-only versions of sequence collections and associative collections. In addition, C++/CX enhances collections by providing three iterator classes that simplify the accessing of collections.
94
94
95
-
Elements of a modifiable collection can be changed, but elements of a read-only collection, which is known as a *view*, can only be read. Elements of a [`Platform::Collections::Vector`](platform-collections-vector-class.md) or[`Platform::Collections::VectorView`](platform-collections-vectorview-class.md) collection can be accessed by using an iterator or the collection's [`Vector::GetAt`](platform-collections-vector-class.md#getat) and an index. Elements of an associative collection can be accessed by using the collection's [`Map::Lookup`](platform-collections-map-class.md#lookup) and a key.
95
+
Elements of a modifiable collection can be changed, but elements of a read-only collection, which is known as a *view*, can only be read. Elements of a [`Platform::Collections::Vector`](platform-collections-vector-class.md) or[`Platform::Collections::VectorView`](platform-collections-vectorview-class.md) collection can be accessed by using an iterator or the collection's [`Vector::GetAt`](platform-collections-vector-class.md#getat) and an index. Elements of an associative collection can be accessed by using the collection's [`Map::Lookup`](platform-collections-map-class.md#lookup) and a key.
A modifiable, associative collection. Map elements are key-value pairs. Looking up a key to retrieve its associated value, and iterating through all key-value pairs, are both supported.
@@ -128,14 +128,14 @@ The following table lists the available iterators and functions.
128
128
|[`Platform::Collections::VectorIterator<T>`](platform-collections-vectoriterator-class.md)<br /><br /> (Internally stores [`Windows::Foundation::Collections::IVector<T>`](/uwp/api/windows.foundation.collections.ivector-1) and `int`.)|[`begin`](begin-function.md)/ [`end`](end-function.md)([`Windows::Foundation::Collections::IVector<T>`](/uwp/api/windows.foundation.collections.ivector-1))|
129
129
|[`Platform::Collections::VectorViewIterator<T>`](platform-collections-vectorviewiterator-class.md)<br /><br /> (Internally stores [`IVectorView<T>`](/uwp/api/windows.foundation.collections.ivectorview-1)^ and `int`.)|[`begin`](begin-function.md)/ [`end`](end-function.md) ([`IVectorView<T>`](/uwp/api/windows.foundation.collections.ivectorview-1)^)|
130
130
|[`Platform::Collections::InputIterator<T>`](platform-collections-inputiterator-class.md)<br /><br /> (Internally stores [`IIterator<T>`](/uwp/api/windows.foundation.collections.iiterator-1)^ and `T`.)|[`begin`](begin-function.md)/ [`end`](end-function.md) ([`IIterable<T>`](/uwp/api/windows.foundation.collections.iiterable-1))|
`Vector` and `Map` support databinding in XAML collections by implementing events that occur when a collection object is changed or reset, or when any element of a collection is inserted, removed, or changed. You can write your own types that support databinding, although you cannot inherit from `Map` or `Vector` because those types are sealed.
137
137
138
-
The [`Windows::Foundation::Collections::VectorChangedEventHandler`](/uwp/api/windows.foundation.collections.vectorchangedeventhandler-1) and [`Windows::Foundation::Collections::MapChangedEventHandler`](/uwp/api/windows.foundation.collections.mapchangedeventhandler-2) delegates specify the signatures for event handlers for collection change events. The [`Windows::Foundation::Collections::CollectionChange`](/uwp/api/windows.foundation.collections.collectionchange) public enum class, and `Platform::Collection::Details::MapChangedEventArgs` and `Platform::Collections::Details::VectorChangedEventArgs` ref classes, store the event arguments to determine what caused the event. The `*EventArgs` types are defined in the `Details` namespace because you don't have to construct or consume them explicitly when you use `Map` or `Vector`.
138
+
The [`Windows::Foundation::Collections::VectorChangedEventHandler`](/uwp/api/windows.foundation.collections.vectorchangedeventhandler-1) and [`Windows::Foundation::Collections::MapChangedEventHandler`](/uwp/api/windows.foundation.collections.mapchangedeventhandler-2) delegates specify the signatures for event handlers for collection change events. The [`Windows::Foundation::Collections::CollectionChange`](/uwp/api/windows.foundation.collections.collectionchange) public enum class, and `Platform::Collections::Details::MapChangedEventArgs` and `Platform::Collections::Details::VectorChangedEventArgs` ref classes, store the event arguments to determine what caused the event. The `*EventArgs` types are defined in the `Details` namespace because you don't have to construct or consume them explicitly when you use `Map` or `Vector`.
0 commit comments