示例#1
0
 /// <summary>現在のノードの次に兄弟ノードを追加する。</summary>
 /// <param name="self">対象ノード</param>
 /// <param name="sibling">追加する兄弟ノード</param>
 /// <returns>正常に追加できたかどうか示す値と現在のノードを返す。</returns>
 public static ResultWithValue <T> MaybeInsertNextSibling <T>(this ITreeNode <T> self, ITreeNode <T> sibling)
     where T : ITreeNode <T>
 {
     if (self.Parent != null)
     {
         var cash  = self.Children.Count;
         var ncash = self.Parent.InsertChild(self.BranchIndex() + 1, (T)sibling).Children.ToArray();
         if (cash + 1 == ncash.Length && ncash.Contains((T)sibling))
         {
             return(new ResultWithValue <T>((T)self));
         }
     }
     return(new ResultWithValue <T>(false, (T)self));
 }