Skip to content

Mutable vectors (and possibly arrays) should support having zero elements inside #149

@utdemir

Description

@utdemir

Currently, our linear mutable Array and Vector implementations require the collection to always contain at least one element inside.

Especially when using a Vector, it is common to start with an empty vector and append new elements to it. Having it require an element to start with is unusual, so we should support having zero elements inside (this includes resizing to zero elements) and provide an empty method.

I think this choice stems from Unsafe.MutableArray.newMutArr's precondition that the size should be positive. However, I did a few quick tests and it seems to be happy when the size is 0 too. So we can probably relax that requirement and the Vector and Array changes would follow.

This issue is broken up from: #146

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions