microsoft / microsoft/WindowsAppSDK

Proposal: Add IReserveableVector to WinRT

Open
#6,768 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triage
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 least capacity elements without reallocation.
  • If capacity is less than or equal to the current capacity, the call is a no-op.
  • If capacity is smaller than Size, it does not shrink the vector; existing elements are preserved.
  • The method does not change Size or insert elements.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.