Example #1
0
 /// <summary>
 /// Splits the original span with the given splitter
 /// </summary>
 /// <param name="original">The span to be split</param>
 /// <param name="splitter">The splitter</param>
 /// <param name="rest">The second part of the resulting split</param>
 /// <returns>The first part of the resulting split</returns>
 public static CharSpan Split(CharSpan original, CharSpan splitter, out CharSpan rest)
 {
     if (original.spanBegin == splitter.spanBegin)
     {
         rest = NULL;
         if (original.spanEnd == splitter.spanEnd)
         {
             return(NULL);
         }
         return(new CharSpan(Convert.ToChar(splitter.spanEnd + 1), original.spanEnd));
     }
     if (original.spanEnd == splitter.spanEnd)
     {
         rest = NULL;
         return(new CharSpan(original.spanBegin, Convert.ToChar(splitter.spanBegin - 1)));
     }
     rest = new CharSpan(Convert.ToChar(splitter.spanEnd + 1), original.spanEnd);
     return(new CharSpan(original.spanBegin, Convert.ToChar(splitter.spanBegin - 1)));
 }
Example #2
0
 /// <summary>
 /// Compares the left and right spans for a decreasing order sort
 /// </summary>
 /// <param name="left">The left span</param>
 /// <param name="right">The right span</param>
 /// <returns>The order between left and right</returns>
 public static int CompareReverse(CharSpan left, CharSpan right)
 {
     return(right.spanBegin.CompareTo(left.spanBegin));
 }