FSharp.Collections.Immutable 1.0.0

Edit this page

FlatListBuilder Module

Functions for the builder of a flat list, Builder.

The builder is mutable. The functions that change it return the same builder, so that the calls chain with the pipe operator. FlatList.builder creates a builder, and FlatList.ofBuilder returns its contents as a flat list.

Functions and values

Function or value Description

FlatListBuilder.add value builder

Full Usage: FlatListBuilder.add value builder

Parameters:
    value : 'T - The value to add.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Adds a value after the last element.

value : 'T

The value to add.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

FlatListBuilder.addRange values builder

Full Usage: FlatListBuilder.addRange values builder

Parameters:
    values : 'T seq - The values to add.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Adds values after the last element.

values : 'T seq

The values to add.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

ArgumentNullException Thrown when values is or a default flat list.

FlatListBuilder.blit source sourceIndex target targetIndex count

Full Usage: FlatListBuilder.blit source sourceIndex target targetIndex count

Parameters:
    source : Builder<'T> - The builder.
    sourceIndex : int - The index of the first element to copy.
    target : 'T array - The array to copy to.
    targetIndex : int - The index in the target array of the first copied element.
    count : int - The number of elements to copy.

Copies a range of the builder into an array.

O(count). The function wraps Builder.CopyTo. It names the parameters target, targetIndex and count where the BCL names them destination, destinationIndex and length.

source : Builder<'T>

The builder.

sourceIndex : int

The index of the first element to copy.

target : 'T array

The array to copy to.

targetIndex : int

The index in the target array of the first copied element.

count : int

The number of elements to copy.

ArgumentNullException Thrown when target is .
ArgumentOutOfRangeException Thrown when a range is outside its builder or array.

FlatListBuilder.capacity builder

Full Usage: FlatListBuilder.capacity builder

Parameters:
    builder : Builder<'T> - The builder.

Returns: int The capacity.

Returns the number of elements that the builder can hold without growing.

builder : Builder<'T>

The builder.

Returns: int

The capacity.

FlatListBuilder.clear builder

Full Usage: FlatListBuilder.clear builder

Parameters:
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Removes every element.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

FlatListBuilder.contains value builder

Full Usage: FlatListBuilder.contains value builder

Parameters:
    value : 'T - The value to find.
    builder : Builder<'T> - The builder.

Returns: bool when an element equals the value.

Returns whether the builder contains a value, in EqualityComparer.

value : 'T

The value to find.

builder : Builder<'T>

The builder.

Returns: bool

when an element equals the value.

FlatListBuilder.drainToFlatList builder

Full Usage: FlatListBuilder.drainToFlatList builder

Parameters:
    builder : Builder<'T> - The builder.

Returns: FlatList<'T> The flat list of the elements; without a copy when the count equals the capacity.

Returns the contents of the builder as a flat list and empties the builder.

builder : Builder<'T>

The builder.

Returns: FlatList<'T>

The flat list of the elements; without a copy when the count equals the capacity.

FlatListBuilder.indexOf value builder

Full Usage: FlatListBuilder.indexOf value builder

Parameters:
    value : 'T - The value to find.
    builder : Builder<'T> - The builder.

Returns: int The index, or -1.

Returns the index of the first element equal to a value, or -1.

value : 'T

The value to find.

builder : Builder<'T>

The builder.

Returns: int

The index, or -1.

FlatListBuilder.indexOfRange startIndex count value builder

Full Usage: FlatListBuilder.indexOfRange startIndex count value builder

Parameters:
    startIndex : int - The index of the first element of the range.
    count : int - The number of elements of the range.
    value : 'T - The value to find.
    builder : Builder<'T> - The builder.

Returns: int The index in the builder of the first equal element of the range, or -1.

Returns the index of the first element equal to a value in a range, in EqualityComparer.

O(count). The function wraps Builder.IndexOf.

The function throws what the BCL member throws. The member of .NET 8 and .NET 10 rejects also an empty range at a start index that equals the count of the builder, and it accepts for an empty builder only the start index 0 with the count 0, which gives -1.

startIndex : int

The index of the first element of the range.

count : int

The number of elements of the range.

value : 'T

The value to find.

builder : Builder<'T>

The builder.

Returns: int

The index in the builder of the first equal element of the range, or -1.

ArgumentOutOfRangeException Thrown when startIndex or count is outside the builder.

FlatListBuilder.indexOfRangeWith comparer startIndex count value builder

Full Usage: FlatListBuilder.indexOfRangeWith comparer startIndex count value builder

Parameters:
    comparer : IEqualityComparer<'T> - The equality comparer. stands for EqualityComparer.
    startIndex : int - The index of the first element of the range.
    count : int - The number of elements of the range.
    value : 'T - The value to find.
    builder : Builder<'T> - The builder.

Returns: int The index in the builder of the first equal element of the range, or -1.

Returns the index of the first element equal to a value in a range, in a given equality comparer.

O(count). The function wraps Builder.IndexOf.

The function throws what the BCL member throws. The member of .NET 8 and .NET 10 rejects also an empty range at a start index that equals the count of the builder, and it accepts for an empty builder only the start index 0 with the count 0, which gives -1.

comparer : IEqualityComparer<'T>

The equality comparer. stands for EqualityComparer.

startIndex : int

The index of the first element of the range.

count : int

The number of elements of the range.

value : 'T

The value to find.

builder : Builder<'T>

The builder.

Returns: int

The index in the builder of the first equal element of the range, or -1.

ArgumentOutOfRangeException Thrown when startIndex or count is outside the builder.

FlatListBuilder.insertAt index value builder

Full Usage: FlatListBuilder.insertAt index value builder

Parameters:
    index : int - The index of the inserted value, from 0 to the count.
    value : 'T - The value to insert.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Inserts a value at an index.

index : int

The index of the inserted value, from 0 to the count.

value : 'T

The value to insert.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

ArgumentOutOfRangeException Thrown when the index is out of range.

FlatListBuilder.insertManyAt index values builder

Full Usage: FlatListBuilder.insertManyAt index values builder

Parameters:
    index : int - The index of the first inserted value, from 0 to the count.
    values : 'T seq - The values to insert.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Inserts values at an index.

O(n + m) for m values. The function wraps Builder.InsertRange. The index is checked before the values, as the BCL member does.

index : int

The index of the first inserted value, from 0 to the count.

values : 'T seq

The values to insert.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

ArgumentOutOfRangeException Thrown when the index is out of range.
ArgumentNullException Thrown when values is or a default flat list.

FlatListBuilder.item index builder

Full Usage: FlatListBuilder.item index builder

Parameters:
    index : int - The index of the element.
    builder : Builder<'T> - The builder.

Returns: 'T The element.

Returns the element at an index.

index : int

The index of the element.

builder : Builder<'T>

The builder.

Returns: 'T

The element.

IndexOutOfRangeException Thrown when the index is out of range.

FlatListBuilder.lastIndexOf value builder

Full Usage: FlatListBuilder.lastIndexOf value builder

Parameters:
    value : 'T - The value to find.
    builder : Builder<'T> - The builder.

Returns: int The index, or -1.

Returns the index of the last element equal to a value, or -1.

value : 'T

The value to find.

builder : Builder<'T>

The builder.

Returns: int

The index, or -1.

FlatListBuilder.lastIndexOfRange startIndex count value builder

Full Usage: FlatListBuilder.lastIndexOfRange startIndex count value builder

Parameters:
    startIndex : int - The index of the last element of the range, where the search starts.
    count : int - The number of elements of the range, counted backward from the start index.
    value : 'T - The value to find.
    builder : Builder<'T> - The builder.

Returns: int The index in the builder of the last equal element of the range, or -1.

Returns the index of the last element equal to a value in a range that is searched backward, in EqualityComparer.

O(count). The range holds the elements from startIndex down to startIndex - count + 1. The function wraps Builder.LastIndexOf.

The function throws what the BCL member throws. The member of .NET 8 and .NET 10 rejects also an empty range at a start index that equals the count of the builder, and it accepts for an empty builder only the start index 0 with the count 0, which gives -1.

startIndex : int

The index of the last element of the range, where the search starts.

count : int

The number of elements of the range, counted backward from the start index.

value : 'T

The value to find.

builder : Builder<'T>

The builder.

Returns: int

The index in the builder of the last equal element of the range, or -1.

ArgumentOutOfRangeException Thrown when startIndex or count is outside the builder.

FlatListBuilder.lastIndexOfRangeWith comparer startIndex count value builder

Full Usage: FlatListBuilder.lastIndexOfRangeWith comparer startIndex count value builder

Parameters:
    comparer : IEqualityComparer<'T> - The equality comparer. stands for EqualityComparer.
    startIndex : int - The index of the last element of the range, where the search starts.
    count : int - The number of elements of the range, counted backward from the start index.
    value : 'T - The value to find.
    builder : Builder<'T> - The builder.

Returns: int The index in the builder of the last equal element of the range, or -1.

Returns the index of the last element equal to a value in a range that is searched backward, in a given equality comparer.

O(count). The range holds the elements from startIndex down to startIndex - count + 1. The function wraps Builder.LastIndexOf.

The function throws what the BCL member throws. The member of .NET 8 and .NET 10 rejects also an empty range at a start index that equals the count of the builder, and it accepts for an empty builder only the start index 0 with the count 0, which gives -1.

comparer : IEqualityComparer<'T>

The equality comparer. stands for EqualityComparer.

startIndex : int

The index of the last element of the range, where the search starts.

count : int

The number of elements of the range, counted backward from the start index.

value : 'T

The value to find.

builder : Builder<'T>

The builder.

Returns: int

The index in the builder of the last equal element of the range, or -1.

ArgumentOutOfRangeException Thrown when startIndex or count is outside the builder.

FlatListBuilder.length builder

Full Usage: FlatListBuilder.length builder

Parameters:
    builder : Builder<'T> - The builder.

Returns: int The number of elements.

Returns the number of elements in the builder.

builder : Builder<'T>

The builder.

Returns: int

The number of elements.

FlatListBuilder.remove value builder

Full Usage: FlatListBuilder.remove value builder

Parameters:
    value : 'T - The value to remove.
    builder : Builder<'T> - The builder.

Returns: bool when an element was removed.

Removes the first element equal to a value, in EqualityComparer.

value : 'T

The value to remove.

builder : Builder<'T>

The builder.

Returns: bool

when an element was removed.

FlatListBuilder.removeAll predicate builder

Full Usage: FlatListBuilder.removeAll predicate builder

Parameters:
    predicate : 'T -> bool - The function to test the elements.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Removes every element that satisfies a predicate.

O(n). The function wraps Builder.RemoveAll.

predicate : 'T -> bool

The function to test the elements.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

FlatListBuilder.removeAt index builder

Full Usage: FlatListBuilder.removeAt index builder

Parameters:
    index : int - The index of the removed element.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Removes the element at an index.

index : int

The index of the removed element.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

ArgumentOutOfRangeException Thrown when the index is out of range.

FlatListBuilder.removeMany items builder

Full Usage: FlatListBuilder.removeMany items builder

Parameters:
    items : 'T seq - The values to remove.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Removes one element for each of the given values, in EqualityComparer.

O(n * m) for m values. Each value removes the first remaining element that equals it; a value that equals no remaining element removes nothing. The function wraps Builder.RemoveRange.

items : 'T seq

The values to remove.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

ArgumentNullException Thrown when items is or a default flat list.

FlatListBuilder.removeManyAt index count builder

Full Usage: FlatListBuilder.removeManyAt index count builder

Parameters:
    index : int - The index of the first removed element.
    count : int - The number of removed elements.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Removes a range of elements.

O(n). The function wraps Builder.RemoveRange. It names the parameter count where the BCL names it length.

index : int

The index of the first removed element.

count : int

The number of removed elements.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

ArgumentOutOfRangeException Thrown when index is out of range, or count is negative or the range extends beyond the end of the builder.

FlatListBuilder.removeManyWith comparer items builder

Full Usage: FlatListBuilder.removeManyWith comparer items builder

Parameters:
Returns: Builder<'T> The same builder.

Removes one element for each of the given values, in a given equality comparer.

O(n * m) for m values. Each value removes the first remaining element that equals it; a value that equals no remaining element removes nothing. The function wraps Builder.RemoveRange.

comparer : IEqualityComparer<'T>

The equality comparer. stands for EqualityComparer.

items : 'T seq

The values to remove.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

ArgumentNullException Thrown when items is or a default flat list.

FlatListBuilder.removeWith comparer value builder

Full Usage: FlatListBuilder.removeWith comparer value builder

Parameters:
Returns: bool when an element was removed.

Removes the first element equal to a value, in a given equality comparer.

O(n). The function wraps Builder.Remove.

comparer : IEqualityComparer<'T>

The equality comparer. stands for EqualityComparer.

value : 'T

The value to remove.

builder : Builder<'T>

The builder.

Returns: bool

when an element was removed.

FlatListBuilder.replace oldValue newValue builder

Full Usage: FlatListBuilder.replace oldValue newValue builder

Parameters:
    oldValue : 'T - The value to replace.
    newValue : 'T - The new value.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Replaces the first element that equals a value with another value, in EqualityComparer.

O(n). The function wraps Builder.Replace.

The builder stays as it is when no element equals the old value: the BCL member does not throw. The function FlatList.replace of the flat list throws ArgumentException in that case.

oldValue : 'T

The value to replace.

newValue : 'T

The new value.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

FlatListBuilder.replaceWith comparer oldValue newValue builder

Full Usage: FlatListBuilder.replaceWith comparer oldValue newValue builder

Parameters:
Returns: Builder<'T> The same builder.

Replaces the first element that equals a value with another value, in a given equality comparer.

O(n). The function wraps Builder.Replace.

The builder stays as it is when no element equals the old value: the BCL member does not throw. The function FlatList.replaceWith of the flat list throws ArgumentException in that case.

comparer : IEqualityComparer<'T>

The equality comparer. stands for EqualityComparer.

oldValue : 'T

The value to replace.

newValue : 'T

The new value.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

FlatListBuilder.rev builder

Full Usage: FlatListBuilder.rev builder

Parameters:
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Reverses the order of the elements.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

FlatListBuilder.setCapacity capacity builder

Full Usage: FlatListBuilder.setCapacity capacity builder

Parameters:
    capacity : int - The new capacity, not less than the count.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Sets the number of elements that the builder can hold without growing.

capacity : int

The new capacity, not less than the count.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

ArgumentException Thrown when the capacity is less than the count.

FlatListBuilder.sort builder

Full Usage: FlatListBuilder.sort builder

Parameters:
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Sorts the elements in the order of F# generic comparison.

This is not a stable sort.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

FlatListBuilder.sortRange index count builder

Full Usage: FlatListBuilder.sortRange index count builder

Parameters:
    index : int - The index of the first element of the range.
    count : int - The number of elements of the range.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Sorts a range of the elements in the order of F# generic comparison.

O(count log count). This is not a stable sort. The elements outside the range keep their places. The function wraps Builder.Sort.

index : int

The index of the first element of the range.

count : int

The number of elements of the range.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

ArgumentOutOfRangeException Thrown when index or count is negative, or the range extends beyond the end of the builder.

FlatListBuilder.sortRangeWith comparison index count builder

Full Usage: FlatListBuilder.sortRangeWith comparison index count builder

Parameters:
    comparison : 'T -> 'T -> int - The function that compares two elements.
    index : int - The index of the first element of the range.
    count : int - The number of elements of the range.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Sorts a range of the elements with a comparison function.

O(count log count). This is not a stable sort. The elements outside the range keep their places. The function wraps Builder.Sort.

comparison : 'T -> 'T -> int

The function that compares two elements.

index : int

The index of the first element of the range.

count : int

The number of elements of the range.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

ArgumentOutOfRangeException Thrown when index or count is negative, or the range extends beyond the end of the builder.

FlatListBuilder.sortRangeWithComparer comparer index count builder

Full Usage: FlatListBuilder.sortRangeWithComparer comparer index count builder

Parameters:
    comparer : IComparer<'T> - The comparer. stands for Comparer.
    index : int - The index of the first element of the range.
    count : int - The number of elements of the range.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Sorts a range of the elements with a comparer.

O(count log count). This is not a stable sort. The elements outside the range keep their places. The function wraps Builder.Sort.

comparer : IComparer<'T>

The comparer. stands for Comparer.

index : int

The index of the first element of the range.

count : int

The number of elements of the range.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

ArgumentOutOfRangeException Thrown when index or count is negative, or the range extends beyond the end of the builder.

FlatListBuilder.sortWith comparer builder

Full Usage: FlatListBuilder.sortWith comparer builder

Parameters:
    comparer : 'T -> 'T -> int - The function that compares two elements.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Sorts the elements with a comparison function.

This is not a stable sort.

comparer : 'T -> 'T -> int

The function that compares two elements.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

FlatListBuilder.sortWithComparer comparer builder

Full Usage: FlatListBuilder.sortWithComparer comparer builder

Parameters:
Returns: Builder<'T> The same builder.

Sorts the elements with a comparer.

This is not a stable sort.

comparer : IComparer<'T>

The comparer.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

FlatListBuilder.toArray builder

Full Usage: FlatListBuilder.toArray builder

Parameters:
    builder : Builder<'T> - The builder.

Returns: 'T array A copy of the elements.

Returns a new array with the elements of the builder.

builder : Builder<'T>

The builder.

Returns: 'T array

A copy of the elements.

FlatListBuilder.updateAt index value builder

Full Usage: FlatListBuilder.updateAt index value builder

Parameters:
    index : int - The index of the replaced element.
    value : 'T - The new value.
    builder : Builder<'T> - The builder.

Returns: Builder<'T> The same builder.

Replaces the element at an index.

index : int

The index of the replaced element.

value : 'T

The new value.

builder : Builder<'T>

The builder.

Returns: Builder<'T>

The same builder.

IndexOutOfRangeException Thrown when the index is out of range.