A FlatList<'T> is an ImmutableArray<'T>: a function that adds an element returns a new array. To build a flat list
from many pieces, collect the elements first and create the flat list once.
|
flatList { } takes yield, yield!, loops and conditions, and creates the flat list when the expression ends:
|
FlatList.build gives a builder to a function and returns the flat list of the elements that the function added. The
functions of the FlatListBuilder module that change the builder return it, so they form a pipeline:
|
FlatList.update does the same with the elements of an existing flat list, which stays unchanged:
|
FlatList.builderWith creates a builder of a given capacity. When the builder is full, FlatList.moveFromBuilder gives
its array to the flat list without a copy and empties the builder:
|
FlatList.moveFromBuilder throws InvalidOperationException when the count of the builder differs from its capacity.
FlatList.ofBuilder copies the elements and takes a builder of any count.