Hacker News new | past | comments | ask | show | jobs | submit login

Comparisons with ImmutableList<T> from Microsoft aren't necessarily valid, since ImmutableList<T> supports insertion and removal at arbitrary points. The implementation in the article is optimized for adding at the end.



That's why there are two separate methods on this class - Add (at the end) and Set (anywhere). Both outperform the corresponding ImmutableList<T>, according to the article.


Set is the corollary to SetItem on ImmutableList<T>, not Insert.


But Set can just overwrites the specified element while Insert will insert the element at the specified position by pushing the element and all following elements out of the way.


> But Set can just overwrites the specified element

Kind of: Set returns a new Vector with a changed state (the specified element overwritten).

But yes, this implement is very sparse: there's no way to add and remove elements in the middle, no way to even tell how many elements are in the list: https://news.ycombinator.com/item?id=8592178

Perhaps omitting them hides some different optimisation choices (i.e. they would be more expensive)

Maybe it's just a proof of concept?




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: