protected StringData(StringData sd) { _spanFactory = sd._spanFactory; _str = new StringBuilder(sd._str.ToString()); _span = sd._span; _annotations = sd._annotations.DeepClone(); }
public StringData(SpanFactory <int> spanFactory, string str) { _spanFactory = spanFactory; _str = new StringBuilder(str); _span = _spanFactory.Create(0, _str.Length); _annotations = new AnnotationList <int>(spanFactory); }
private void UpdateAnnotations(AnnotationList <ShapeNode> annList, ShapeNode node) { if (annList.Count == 0) { return; } Annotation <ShapeNode> startAnn; annList.Find(node, Direction.LeftToRight, out startAnn); if (startAnn == annList.Begin) { startAnn = annList.First; } Annotation <ShapeNode> endAnn; annList.Find(node, Direction.RightToLeft, out endAnn); if (endAnn == annList.End) { endAnn = annList.Last; } if (startAnn.CompareTo(endAnn) > 0) { return; } foreach (Annotation <ShapeNode> ann in annList.GetNodes(startAnn, endAnn).Where(ann => ann.Span.Contains(node)).ToArray()) { if (!ann.IsLeaf) { UpdateAnnotations(ann.Children, node); } if (ann.Span.Start == node && ann.Span.End == node) { annList.Remove(ann); } else if (ann.Span.Start == node || ann.Span.End == node) { Span <ShapeNode> span = ann.Span.Start == node?_spanFactory.Create(node.Next, ann.Span.End) : _spanFactory.Create(ann.Span.Start, node.Prev); var newAnn = new Annotation <ShapeNode>(span, ann.FeatureStruct.DeepClone()) { Optional = ann.Optional }; if (!ann.IsLeaf) { foreach (Annotation <ShapeNode> child in ann.Children.ToArray()) { newAnn.Children.Add(child, false); } } annList.Remove(ann, false); annList.Add(newAnn, false); } } }
public Shape(SpanFactory <ShapeNode> spanFactory, Func <bool, ShapeNode> marginSelector, AnnotationList <ShapeNode> annotations) : base(EqualityComparer <ShapeNode> .Default, marginSelector) { _marginSelector = marginSelector; _spanFactory = spanFactory; _annotations = annotations; Begin.Tag = int.MinValue; End.Tag = int.MaxValue; _annotations.Add(Begin.Annotation, false); _annotations.Add(End.Annotation, false); }
public bool ValueEquals(AnnotationList <TOffset> other) { if (other == null) { return(false); } if (Count != other.Count) { return(false); } return(this.SequenceEqual(other, FreezableEqualityComparer <Annotation <TOffset> > .Default)); }
private void CopyAnnotations(AnnotationList <ShapeNode> destList, Annotation <ShapeNode> ann, Dictionary <ShapeNode, ShapeNode> mapping) { if (ann.Span.Start.Annotation == ann) { destList.Add(mapping[ann.Span.Start].Annotation, false); } else { var newAnn = new Annotation <ShapeNode>(_spanFactory.Create(mapping[ann.Span.Start], mapping[ann.Span.End]), ann.FeatureStruct.DeepClone()); destList.Add(newAnn, false); if (!ann.IsLeaf) { foreach (Annotation <ShapeNode> child in ann.Children) { CopyAnnotations(newAnn.Children, child, mapping); } } } }
protected AnnotationList(AnnotationList <TOffset> annList) : this(annList._spanFactory) { AddRange(annList.Select(ann => ann.DeepClone())); }