import { type List } from "https://deno.land/x/rimbu@1.2.0/core/mod.ts";
const { Builder } = List;
A mutable builder to create immutable List
instances in a more efficient way.
See the List documentation and the List.Builder API documentation
Examples
Example 1
Example 1
const b = List.builder<T>();
b.append(1);
b.prepend(2);
b.insert(1, 3);
b.build().toArray();
// => [2, 3, 1]
Methods
get(index: number): T | undefined
Returns the value in the List builder at the given index
.
Updates the element at the given index
with the given update
value or function.
prepend(value: T): void
Adds the given value
to the start of the builder values.
append(value: T): void
Adds the given value
to the end of the builder values.
appendAll(values: StreamSource<T>): void
Adds all given values
at the end of the builder values
insert(index: number, value: T): void
Inserts the given value
at the given index
in the builder.
remove(index: number): T | undefined
Removes the value at the given index
in the builder.
forEach(f: () => void, options?: { reversed?: boolean; state?: TraverseState; }): void
Performs given function f
for each value of the List builder.