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
Currently, our linear mutable
ArrayandVectorimplementations 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 anemptymethod.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 theVectorandArraychanges would follow.This issue is broken up from: #146