Пример #1
0
        void PlaceinTheList(Mochila x)
        {
            if (x.Position().Equals(0))
            {
                listBox1.Items.Clear();
            }
            if (x.Next() != null)
            {
                if (x.Previous() != null)
                {
                    listBox1.Items.Add(x.Position() + ": Mochila " + x.Index() + " e dentro tem a " +
                                       x.Next().Index() +
                                       " e está dentro da " + x.Previous().Index());
                }
                else
                {
                    listBox1.Items.Add(x.Position() + ": Mochila " + x.Index() + " e dentro tem a " +
                                       x.Next().Index() + " e não está dentro de nenhuma");
                }

                PlaceinTheList(x.Next());
            }
            else
            {
                if (x.Previous() != null)
                {
                    listBox1.Items.Add(x.Position() + ": Mochila " + x.Index() + " e dentro tem nada e está dentro da " + x.Previous().Index());
                }
                else
                {
                    listBox1.Items.Add(x.Position() + ": Mochila " + x.Index() + " e dentro tem nada e não está dentro de nenhuma");
                }
                textBox4.Text = (x.Position() + 1).ToString();
            }
        }
Пример #2
0
 Mochila GoToEnd(Mochila x)
 {
     if (x.Next() != null)
     {
         x = GoToEnd(x.Next());
     }
     return(x);
 }
Пример #3
0
 Mochila GetByPositon(Mochila x, float position)
 {
     if (x.Position() != position)
     {
         x = GetByPositon(x.Next(), position);
     }
     return(x);
 }
Пример #4
0
 Mochila AddEnd(Mochila x, int posicao, int tamanho)
 {
     if (x.Index() >= tamanho)
     {
         tamanho = x.Index() + 1;
     }
     if (x.Next() != null)
     {
         x.Next(AddEnd(x.Next(), posicao + 1, tamanho));
     }
     else
     {
         x.Next(new Mochila());
         x.Next().Previous(x);
         x.Next().Position(posicao);
         x.Next().Index(tamanho);
     }
     return(x);
 }
Пример #5
0
 Mochila AddEnd(Mochila x, int position, int index)
 {
     if (x.Index() >= index)
     {
         index = x.Index() + 1;
     }
     if (x.Next() != null)
     {
         x.Next(AddEnd(x.Next(), position + 1, index));
     }
     else
     {
         x.Next(new Mochila());
         x.Next().Previous(x);
         x.Next().Position(position);
         x.Next().Index(index);
     }
     return(x);
 }
Пример #6
0
        void AllBackToPosition(Mochila x, int first)
        {
            if (x.Next() != null)
            {
                if (first.Equals(0))
                {
                    if (x.Previous() != null)
                    {
                        x.Previous().Next(x.Next());
                        x.Next().Previous(x.Previous());
                        x.Next().Position(x.Position());
                    }
                    else
                    {
                        m = x.Next();
                        m.Previous(null);
                        m.Position(0);
                        m.Next().Position(1);
                    }
                }
                else
                {
                    x.Next().Position(x.Position() + 1);
                }

                AllBackToPosition(x.Next(), first + 1);
            }
            else if (first.Equals(0))
            {
                if (x.Previous() != null)
                {
                    x.Previous().Next(null);
                }
                else
                {
                    x = new Mochila();
                }
            }
        }