Skip to content

Commit

Permalink
MergeTree: Initialize DoublyLinkedList from Values (#22753)
Browse files Browse the repository at this point in the history
Small change from a bigger change that adds a constructor to the
DoublyLinkedList class so it can easily be initialized with values
  • Loading branch information
anthony-murphy authored Oct 8, 2024
1 parent 6a75bd0 commit e02cc90
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/dds/merge-tree/src/collections/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ export class DoublyLinkedList<T>
// try to match array signature and semantics where possible
Pick<ListNode<T>[], "pop" | "shift" | "length" | "includes">
{
constructor(values?: Iterable<T>) {
if (values !== undefined) {
this.push(...values);
}
}

find(
predicate: (value: ListNode<T>, obj: DoublyLinkedList<T>) => unknown,
): ListNode<T> | undefined {
Expand Down

0 comments on commit e02cc90

Please sign in to comment.