protected void UpdateFromSequence(IndexedListOnSequence <T> indexedListOnSequence, INonreactiveSequence <T> sequence, int currStartIndex) { IIndexedList <T> indexedList = indexedListOnSequence.IndexedList; if (sequence is ParentSequence <T> parentSequence) { SequenceImmutableArray <ISequence <T> > childSequences = parentSequence.Children; // Remove the old items, if there are any if (_currDescendentItemCount > 0) { indexedList.Update(currStartIndex, _currDescendentItemCount, null); _currDescendentItemCount = 0; } int childSequencesLength = childSequences.Count; _childNodes = new Node[childSequencesLength]; for (int i = 0; i < childSequencesLength; i++) { Node childNode = CreateNode(indexedListOnSequence, childSequences[i], currStartIndex); int childNodeDescendentItemCount = childNode.CurrDescendentItemCount; _childNodes[i] = childNode; _currDescendentItemCount += childNodeDescendentItemCount; currStartIndex += childNodeDescendentItemCount; } } else if (sequence is IItemsSequence <T> itemsSequence) { indexedList.Update(currStartIndex, _currDescendentItemCount, itemsSequence.Items.GetArray()); _childNodes = null; _currDescendentItemCount = itemsSequence.ItemCount; } else { throw new InvalidOperationException($"Unknown Sequence type: {sequence.GetType().FullName}"); } }
public NonreactiveNode(IndexedListOnSequence <T> indexedListOnSequence, INonreactiveSequence <T> sequence, int currStartIndex) { UpdateFromSequence(indexedListOnSequence, sequence, currStartIndex); }