Skip to content

Array with holes #497

Closed
Closed
@bkolobara

Description

@bkolobara

I'm looking for a way to have a small array with big hols between the values. E.g.

var list = List([1, 2]);
list = list.set(10000, 3);
list.forEach( x => {
    console.log(x)
});

Expected output should be:

1
2
undefined (printed out once, not 10000)
3

Right now I get the undefined value printed 10000 times. I would like to be still aware that there are holes when traversing the list, but not store all 10000 undefined values inside the Array.

Maybe I would be able to achieve this using another data structure? As I understand it Immutable.js treats lists as trees. When inserting a new value I don't want all the leafs in between. Reversing it should also work.

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