コード例 #1
0
ファイル: Bead.cs プロジェクト: Shayswisa7/C_sharp
            public static void AddNodeA(IntNode a, int x)
            {
                bool flag = true;

                while (a.GetNext() != null)
                {
                    if (x > a.GetInfo() && x <= a.GetNext().GetInfo())
                    {
                        IntNode c = new IntNode(x, a.GetNext());
                        a.SetNext(c);
                        a    = c;
                        flag = false;
                    }
                    else if (x <= a.GetInfo() && flag)
                    {
                        IntNode c = new IntNode(a.GetInfo(), a.GetNext());
                        a.SetInfo(x);
                        a.SetNext(c);
                        flag = false;
                    }
                    a = a.GetNext();
                }
                if (x > a.GetInfo() && flag)
                {
                    IntNode p = new IntNode(x);
                    a.SetNext(p);
                }
            }
コード例 #2
0
ファイル: Bead.cs プロジェクト: Shayswisa7/C_sharp
            public static IntNode DelNode(IntNode pos)// function for delete a organ in the list
            {
                IntNode a = pos.GetNext();

                pos.SetNext(pos.GetNext().GetNext());
                a.SetNext(null);
                return(a);
            }
コード例 #3
0
ファイル: Bead.cs プロジェクト: Shayswisa7/C_sharp
            public static int LenNode(IntNode allList)// this function return the length node
            {
                int count = 0;

                while (allList.GetNext() != null)
                {
                    allList = allList.GetNext();
                    count++;
                }
                return(count);
            }
コード例 #4
0
ファイル: Bead.cs プロジェクト: Shayswisa7/C_sharp
 public static int LenNodeR(IntNode allList)// this Recursive function return the length node
 {
     if (allList.GetNext() == null)
     {
         return(0);
     }
     else
     {
         allList = allList.GetNext();
         return(1 + LenNodeR(allList));
     }
 }
コード例 #5
0
ファイル: Bead.cs プロジェクト: Shayswisa7/C_sharp
            public static IntNode AddNode(IntNode pos, int a)//function for add a organ in to the list
            {
                IntNode c = new IntNode(a, pos.GetNext());

                pos.SetNext(c);
                return(pos);
            }