public override void Clear() { CheckFrozen(); base.Clear(); _annotations.Clear(); _annotations.Add(Begin.Annotation); _annotations.Add(End.Annotation); }
public void Add() { var annList = new AnnotationList <int>(); // add without subsumption // add to empty list var a = new Annotation <int>(Range <int> .Create(49, 50), FeatureStruct.New().Value); annList.Add(a, false); Assert.AreEqual(1, annList.Count); Assert.AreSame(a, annList.First); // add to beginning of list a = new Annotation <int>(Range <int> .Create(0, 1), FeatureStruct.New().Value); annList.Add(a, false); Assert.AreEqual(2, annList.Count); Assert.AreSame(a, annList.First); // add to end of list a = new Annotation <int>(Range <int> .Create(99, 100), FeatureStruct.New().Value); annList.Add(a, false); Assert.AreEqual(3, annList.Count); Assert.AreSame(a, annList.Last); // add to middle of list a = new Annotation <int>(Range <int> .Create(24, 25), FeatureStruct.New().Value); annList.Add(a, false); Assert.AreEqual(4, annList.Count); Assert.AreSame(a, annList.ElementAt(1)); // add containing annotation a = new Annotation <int>(Range <int> .Create(0, 100), FeatureStruct.New().Value); annList.Add(a, false); Assert.AreEqual(5, annList.Count); Assert.AreSame(a, annList.First()); // add contained annotation a = new Annotation <int>(Range <int> .Create(9, 10), FeatureStruct.New().Value); annList.Add(a, false); Assert.AreEqual(6, annList.Count); Assert.AreSame(a, annList.ElementAt(2)); annList.Clear(); // add with subsumption // add to empty list a = new Annotation <int>(Range <int> .Create(49, 50), FeatureStruct.New().Value); annList.Add(a); Assert.AreEqual(1, annList.Count); Assert.AreSame(a, annList.First); // add to beginning of list a = new Annotation <int>(Range <int> .Create(0, 1), FeatureStruct.New().Value); annList.Add(a); Assert.AreEqual(2, annList.Count); Assert.AreSame(a, annList.First); // add to end of list a = new Annotation <int>(Range <int> .Create(99, 100), FeatureStruct.New().Value); annList.Add(a); Assert.AreEqual(3, annList.Count); Assert.AreSame(a, annList.Last); // add to middle of list a = new Annotation <int>(Range <int> .Create(24, 25), FeatureStruct.New().Value); annList.Add(a); Assert.AreEqual(4, annList.Count); Assert.AreSame(a, annList.ElementAt(1)); // add containing annotation a = new Annotation <int>(Range <int> .Create(0, 100), FeatureStruct.New().Value); annList.Add(a); Assert.AreEqual(1, annList.Count); Assert.AreSame(a, annList.First()); Assert.AreEqual(4, a.Children.Count); // add contained annotation a = new Annotation <int>(Range <int> .Create(9, 10), FeatureStruct.New().Value); annList.Add(a); Assert.AreEqual(1, annList.Count); Assert.AreEqual(5, annList.First.Children.Count); Assert.AreSame(a, annList.First.Children.ElementAt(1)); annList.Clear(); annList.Add(0, 1, FeatureStruct.New().Value); annList.Add(1, 2, FeatureStruct.New().Value); annList.Add(2, 3, FeatureStruct.New().Value); annList.Add(3, 4, FeatureStruct.New().Value); annList.Add(4, 5, FeatureStruct.New().Value); annList.Add(5, 6, FeatureStruct.New().Value); Assert.AreEqual(6, annList.Count); a = new Annotation <int>(Range <int> .Create(1, 5), FeatureStruct.New().Value); a.Children.Add(1, 3, FeatureStruct.New().Value); a.Children.Add(3, 5, FeatureStruct.New().Value); Assert.AreEqual(2, a.Children.Count); annList.Add(a); Assert.AreEqual(3, annList.Count); Assert.AreSame(a, annList.ElementAt(1)); Assert.AreEqual(2, a.Children.Count); Assert.AreEqual(2, a.Children.First.Children.Count); Assert.AreEqual(2, a.Children.Last.Children.Count); }