예제 #1
0
 /// <summary>
 ///  Tries to add another sequence onto the start or end of this one.
 ///  If it succeeds, the other sequence may also be modified and
 ///  should be considered "spent".
 /// </summary>
 /// <param name="other">CoordinateSequence.</param>
 public bool TryAdd(CoordinateSequence other)
 {
     if (LastNode == other.FirstNode)
     {
         //add the sequence at the end
         _nodes.RemoveAt(_nodes.Count - 1);
         AddAll(other);
         MergeTags(other.Tags);
         return(true);
     }
     if (LastNode == other.LastNode)
     {
         //add the sequence backwards at the end
         _nodes.RemoveAt(_nodes.Count - 1);
         other.Reverse();
         AddAll(other);
         MergeTags(other.Tags);
         return(true);
     }
     if (FirstNode == other.LastNode)
     {
         //add the sequence at the beginning
         _nodes.RemoveAt(0);
         AddAll(0, other);
         MergeTags(other.Tags);
         return(true);
     }
     if (FirstNode == other.FirstNode)
     {
         //add the sequence backwards at the beginning
         _nodes.RemoveAt(0);
         other.Reverse();
         AddAll(0, other);
         MergeTags(other.Tags);
         return(true);
     }
     return(false);
 }