microsoft / microsoft/WindowsAppSDK
Proposal: Add IReserveableVector to WinRT
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 471
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 28
Description
This proposal introduces a new WinRT interface, IReserveableVector, that extends IVector<T> with a capacity-reservation method. It allows callers to preallocate storage before bulk insertion, reducing repeated reallocations and improving performance for append-heavy scenarios.
Motivation
IVector<T> exposes size and element access but no way to reserve capacity. When an app appends many elements, the underlying implementation may grow and copy repeatedly. A Reserve method gives callers explicit control over allocation, similar to std::vector::reserve or .NET List<T>.Capacity.
std::vector::reserve can make push_back more than twice as fast, and it can also make IVector::Append more than twice as fast. This usage has existed in C++ for thirty years, but WinRT lacks it. C++/WinRT and C#/WinRT should support implementing this interface when implementing IVector.
Proposed Interface
interface IReserveableVector
{
void Reserve(UInt32 capacity);
}
Behavior
Reserve(capacity)ensures the vector can hold at leastcapacityelements without reallocation.- If
capacityis less than or equal to the current capacity, the call is a no-op. - If
capacityis smaller thanSize, it does not shrink the vector; existing elements are preserved. - The method does not change
Sizeor insert elements.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing WinRT IVector interface definition and its C++/WinRT and C#/WinRT projection or implementation entry points. Review how interface additions are specified and tested, then determine the required Reserve behavior and confirm that size and existing elements remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- api, desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100