public void RemoveOutEdge(ref DynamicArrayBlockAllocator <EdgeIdx> links, ref int start, EdgeIdx edge) { var oldCapacity = this.OutDegree + this.InDegree; var span = links.AsSpan(start, oldCapacity); var i = span.IndexOf(edge); Debug.Assert(i < this.OutDegree); if (this.InDegree > 0) { span[i] = span[this.OutDegree]; span[this.OutDegree] = span[span.Length - 1]; } else { span[i] = span[span.Length - 1]; } if (oldCapacity == 1) { links.Deallocate(start, 1); start = -1; } else { start = links.Resize(start, oldCapacity, oldCapacity - 1); } this.OutDegree--; }
public void AddInEdge(ref DynamicArrayBlockAllocator <EdgeIdx> links, ref int start, EdgeIdx edge) { if (start < 0) { start = links.Allocate(1); this.InDegree = 1; links[start] = edge; return; } var oldCapacity = this.OutDegree + this.InDegree; start = links.Resize(start, oldCapacity, oldCapacity + 1); links[start + oldCapacity] = edge; this.InDegree++; }