IVector<T> Interface
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a random-access collection of elements.
.NET This interface appears to .NET code as System.Collections.Generic.IList<T> due to .NET language projection. In any case where a Windows Runtime type has implemented IVector<T>, .NET code can use the APIs of IList<T> instead.
public interface class IVector : IIterable<T>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.FoundationContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(2436052969, 4513, 17221, 163, 162, 78, 127, 149, 110, 34, 45)]
template <typename T>
struct IVector : IIterable<T>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.FoundationContract), 65536)]
[Windows.Foundation.Metadata.Guid(2436052969, 4513, 17221, 163, 162, 78, 127, 149, 110, 34, 45)]
public interface IList<T> : IEnumerable<T>
Public Interface IList(Of T)
Implements IEnumerable(Of T)
- T
- Attributes
- Implements
Device family |
Windows 10 (introduced in 10.0.10240.0)
|
API contract |
Windows.Foundation.FoundationContract (introduced in v1.0)
|
When programming with .NET, this interface is hidden and developers should use the System.Collections.Generic.IList<T> interface if they want to implement a vector/list type. In any case where a Windows Runtime type has implemented IVector<T>, .NET code can use the APIs of IList<T> instead. This includes all the existing Windows Runtime API and also scenarios such as using the APIs of Windows Runtime components originally implemented in Visual C++ component extensions (C++/CX) from a C# or Visual Basic app.
The IVector<T> interface represents a collection of objects of a specified type that can be individually accessed by index. Properties and methods of IVector<T> support list-type functionality, such as getting the size of the collection, and adding and removing items at specified locations in the collection. Additionally, the GetView method provides a snapshot of the vector whose observable state does not change. The snapshot is useful when you need a view of the collection to refer to in subsequent operations that involve IVector<T>.
Note
Extension functions exist on the C++/WinRT projection types for certain Windows Runtime APIs. For example, winrt::Windows::Foundation::IAsyncAction is the C++/WinRT projection type for IAsyncAction. The extension functions aren't part of the application binary interface (ABI) surface of the actual Windows Runtime types, so they're not listed as members of the Windows Runtime APIs. But you can call them from within any C++/WinRT project. See C++/WinRT functions that extend Windows Runtime APIs.
auto begin() const;
Returns an iterator to the first element of the collection, for use in C++ algorithms such as range-based for
loops.
auto end() const;
Returns an iterator to one past the last element of the collection, for use in C++ algorithms such as range-based for
loops.
IVector inherits IIterable. Types that implement IVector also implement the interface members of IIterable. Similarly, if you're using .NET, there is support for IEnumerable<T>.
Size |
Gets the number of items in the vector. |
Append(T) |
Appends an item to the end of the vector. |
Clear() |
Removes all items from the vector. |
Get |
Returns the item at the specified index in the vector. |
Get |
Retrieves multiple items from the the vector beginning at the given index.
|
Get |
Returns an immutable view of the vector. |
Index |
Retrieves the index of a specified item in the vector. |
Insert |
Inserts an item at a specified index in the vector. |
Remove |
Removes the item at the specified index in the vector. |
Remove |
Removes the last item from the vector. |
Replace |
Replaces all the items in the vector with the specified items. |
Set |
Sets the value at the specified index in the vector. |
Product | Versions |
---|---|
WinRT | Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100 |