public LinkedListStruct(SparseLinkedListBase <T> list) { ListManager = list.Manager; HeadNode = list.HeadNode; TailNode = list.TailNode; LongCount = list.LongCount; }
public Enumerator(SparseLinkedListBase <T> list) { _list = list; _current = default; _currentNode = _list.HeadNode; _currentNodeIndex = -1; _structureVersion = _list.StructureVersion; }
public NodeCursor(long index, SparseLinkedListBase <T> list, NodeBase node, long nodeOffset) { IndexPrivate = index; List = list; NodePrivate = node; NodeOffsetPrivate = nodeOffset; StructureVersion = list?.StructureVersion ?? -1; }
private NodeCursor(long index, SparseLinkedListBase <T> list) { IndexPrivate = index; List = list; NodePrivate = list.HeadNode; NodeOffsetPrivate = 0; StructureVersion = list.StructureVersion; }
private static void MountNode(SparseLinkedListBase <T> .NodeBase node) { Debug.Assert(node.Size == -1); node.Next = null; node.Prev = null; node.Size = 0; }
public InsertEnumerator(T singleItem, SparseLinkedListBase <T> list) { BaseEnumerator = null; List = list; SparseMemorySpan = SparseMemorySpan <T> .Empty; ItemsCount = 0; Current = singleItem; CurrentItemIndex = -1; HasAny = true; }
public InsertEnumerator(IEnumerator <T> baseEnumerator, SparseLinkedListBase <T> list) { BaseEnumerator = baseEnumerator; List = list; SparseMemorySpan = SparseMemorySpan <T> .Empty; ItemsCount = 0; CurrentItemIndex = 0; HasAny = baseEnumerator.MoveNext(); Current = baseEnumerator.Current; }
public void ReleaseNode(SparseLinkedListBase <T> .NodeBase node) { OnNodeReleasing(node); node.Release(); if (node is SparseLinkedListBase <T> .GapNode gapNode) { GapNodePool.Push(gapNode); } else if (node is SparseLinkedListBase <T> .RealizedNode realizedNode) { RealizedNodePool.Push(realizedNode); } OnNodeReleased(node); }
private protected void SwapImpl(SparseLinkedListBase <T> targetList) { try { EnterStructureChange(); targetList.EnterStructureChange(); var left = new LinkedListStruct(this); var right = new LinkedListStruct(targetList); left.Store(targetList); right.Store(this); } finally { LeaveStructureChange(); targetList.LeaveStructureChange(); } }
private protected void MergeImpl(SparseLinkedListBase <T> sourceList) { if (ReferenceEquals(this, sourceList)) { throw new InvalidOperationException("Cannot split into self"); } if (ReferenceEquals(Manager, sourceList.Manager) == false) { throw new InvalidOperationException("Manager of source list and target list must be the same"); } if (sourceList.LongCount == 0) { return; } try { EnterStructureChange(); sourceList.EnterStructureChange(); var first = new LinkedListStruct(this); var second = new LinkedListStruct(sourceList); first.Merge(ref second); first.Store(this); second.Store(sourceList); } finally { LeaveStructureChange(); sourceList.LeaveStructureChange(); } }
private protected void SplitAtImpl(long index, SparseLinkedListBase <T> targetList) { if (ReferenceEquals(this, targetList)) { throw new InvalidOperationException("Cannot split into self"); } if (ReferenceEquals(Manager, targetList.Manager) == false) { throw new InvalidOperationException("Manager of source list and target list must be the same"); } if (index == LongCount) { return; } try { EnterStructureChange(); targetList.EnterStructureChange(); if (index == 0) { if (targetList.LongCount == 0) { SwapImpl(targetList); } else { var left = new LinkedListStruct(this); var right = new LinkedListStruct(targetList); left.Merge(ref right); left.Store(targetList); right.Store(this); } return; } var cursor = NavigateTo(index); if (targetList.Count == 0) { var left = new LinkedListStruct(this); var right = new LinkedListStruct(targetList); left.Split(ref cursor, ref right); left.Store(this); right.Store(targetList); } else { var left = new LinkedListStruct(this); var mid = new LinkedListStruct(Manager); var right = new LinkedListStruct(targetList); left.Split(ref cursor, ref mid); mid.Merge(ref right); left.Store(this); mid.Store(targetList); right.Release(); } } finally { LeaveStructureChange(); targetList.LeaveStructureChange(); } }
public void Dispose() { _list = null; _structureVersion = -1; }
public SparseLinkedListNode(SparseLinkedListBase <T> .NodeBase node, SparseLinkedListBase <T> list) { _node = node; _list = list; _version = list.StructureVersion; }
public void ReleaseRealizedNode(SparseLinkedListBase <T> .RealizedNode realizedNode) { RealizedNodePool.Push(realizedNode); }
protected virtual void OnNodeReleasing(SparseLinkedListBase <T> .NodeBase node) { }
public void Store(SparseLinkedListBase <T> list) { list.HeadNode = HeadNode; list.TailNode = TailNode; list.LongCount = LongCount; }