public void Add <T>(ref T copySource, out ListLinkedListNode *page, out int index, Allocator allocator) where T : unmanaged { ListLinkedListNode *tryNode; if (LastFull == null) { tryNode = First; } else { tryNode = LastFull->Next; } for (; tryNode != null; tryNode = tryNode->Next) { if (tryNode->TryAdd(ref copySource, out index)) { if (tryNode->IsFull) { LastFull = tryNode; } page = tryNode; return; } UnityEngine.Debug.Log("LAST FULL RENEW"); LastFull = tryNode; } page = ListLinkedListNode.Create <T>(NodeCapacity, allocator); index = 0; page->GetRef <T>(0) = copySource; page->Length = 1; for (tryNode = LastFull; IntPtr.Zero != Interlocked.CompareExchange(ref tryNode->NextNodePtr, new IntPtr(page), IntPtr.Zero); tryNode = tryNode->Next) { ; } }
public bool MoveNext() { if (isNotFirst) { return((Node = Node->Next) != null); } else { return(isNotFirst = true); } }
public ListLinkedList(int capacity, int size, Allocator allocator) { if (capacity < 1) { throw new ArgumentOutOfRangeException(capacity.ToString() + " must be greater than 0"); } First = (ListLinkedListNode *)UnsafeUtility.Malloc(sizeof(ListLinkedListNode), 4, allocator); *First = new ListLinkedListNode(capacity, size, allocator); NodeCapacity = capacity; LastFull = null; }
public void AddRange <T>(T *copySource, int length, out ListLinkedListNode *page, out int start, Allocator allocator) where T : unmanaged { ListLinkedListNode *tryNode; if (LastFull == null) { tryNode = First; } else if (LastFull->NextNodePtr == IntPtr.Zero) { tryNode = LastFull; goto ADDNEWPAGE; } else { tryNode = LastFull->Next; } if (length > NodeCapacity) { NodeCapacity = length; goto ADDNEWPAGE; } while (true) { if (tryNode->TryAdd(copySource, length, out start)) { if (tryNode->IsFull && LastFull->Next == tryNode) { LastFull = tryNode; } page = tryNode; return; } if (tryNode->NextNodePtr == IntPtr.Zero) { goto ADDNEWPAGE; } tryNode = tryNode->Next; } ADDNEWPAGE: page = ListLinkedListNode.Create <T>(NodeCapacity, allocator); start = 0; UnsafeUtility.MemCpy(page->Values, copySource, sizeof(T) * length); while (IntPtr.Zero != Interlocked.CompareExchange(ref tryNode->NextNodePtr, new IntPtr(page), IntPtr.Zero)) { tryNode = tryNode->Next; } }
public bool MoveNext() { if (Node == null) { return(false); } if (++index == Node->Length) { index = 0; Node = Node->Next; if (Node == null) { return(false); } } return(true); }
public void Dispose() => Node = null;
public void Deconstruct(out int type, out ListLinkedListNode *page, out int index) { type = Type; page = Page; index = Index; }
public ASTTypePageIndexPair(int type) { this.Type = type; this.Page = null; this.Index = default; }