public ArrayRun AddSourcesPointingWithinArray(ModelDelta changeToken) { if (ElementCount < 2) { return(this); } var destinations = new int[ElementCount - 1]; for (int i = 1; i < ElementCount; i++) { destinations[i - 1] = Start + ElementLength * i; } var sources = owner.SearchForPointersToAnchor(changeToken, destinations); var results = new List <List <int> >(); results.Add(PointerSources?.ToList() ?? new List <int>()); for (int i = 1; i < ElementCount; i++) { results.Add(new List <int>()); } foreach (var source in sources) { var destination = owner.ReadPointer(source); int destinationIndex = (destination - Start) / ElementLength; results[destinationIndex].Add(source); } var pointerSourcesForInnerElements = results.Cast <IReadOnlyList <int> >().ToList(); return(new ArrayRun(owner, FormatString, LengthFromAnchor, Start, ElementCount, ElementContent, PointerSources, pointerSourcesForInnerElements)); }
public bool UpdateLimiter(ModelDelta token) { if (PointerSources?.Count != 2) return false; var address = PointerSources.Last() - 4; var limiter = Length / 2 - 2; model.WriteMultiByteValue(address, 4, token, limiter); return true; }
public IFormattedRun MergeAnchor(SortedSpan <int> sources) { if (sources == null) { return(this); } if (PointerSources == null) { return(Clone(sources)); } return(Clone(PointerSources.Add(sources))); }
public override IFormattedRun RemoveSource(int source) { if (!SupportsPointersToElements) { return(base.RemoveSource(source)); } var newPointerSources = PointerSources.Where(item => item != source).ToList(); var newInnerPointerSources = new List <IReadOnlyList <int> >(); foreach (var list in PointerSourcesForInnerElements) { newInnerPointerSources.Add(list.Where(item => item != source).ToList()); } return(new ArrayRun(owner, FormatString, LengthFromAnchor, Start, ElementCount, ElementContent, newPointerSources, newInnerPointerSources)); }
public virtual IFormattedRun RemoveSource(int source) { return(Clone(PointerSources?.Remove1(source) ?? SortedSpan <int> .None)); }
public virtual IFormattedRun RemoveSource(int source) { return(Clone(PointerSources.Remove1(source))); }