eclipse-collections icon indicating copy to clipboard operation
eclipse-collections copied to clipboard

`nCopies` variation of `ImmutableList`

Open dmlloyd opened this issue 2 years ago • 0 comments

It is sometimes useful to have a memory-efficient list comprising a fixed number of copies of a given input. I would propose two variants: one which returns n copies of a single item (similar to java.util.Collections#nCopies; additionally, if n is 0 then the empty list is returned), and one which returns n copies of an inner ImmutableList (if the inner list is empty, then the empty list can be used since n × 0 = 0).

dmlloyd avatar Dec 13 '21 17:12 dmlloyd