Skip to content

Why does StableBuffer<X> store [var X] instead of [var ?X]? #7

@darkdrag00nv2

Description

@darkdrag00nv2

Hi, thanks for this library!

I have noticed a fundamental difference between StableBuffer and the Buffer from the base library. StableBuffer stores [var x] while Buffer stores [var ?X]. This is a small difference but it makes a few things tricky.

Example:
initPresized: As a user, I would expect the method to initialize the buffer of given size when I call it. Instead, this method only updates the capacity and the actual allocation of buffer happens on first add. That's okay but slightly different from expectations. I believe it had to be done this way because we cannot initialize the buffer with all null. So we needed a default value as placeholder which was only available during add. Any method which needs a placeholder will be difficult to write in StableBuffer.

I am sure there is a reason for this. Could you please explain here or even better document it somewhere? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions